@snowcone-app/sdk 0.1.10

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.
@@ -0,0 +1,2437 @@
1
+ export { createDevFetcher } from './dev-fetcher.js';
2
+ import { O as OptionAttribute, a as OptionSelection, C as Combination, b as ComponentProps, F as FrameworkAdapter, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities } from './websocket-B8_XAwWx.js';
3
+ export { A as AdapterRegistry, M as MockupResult, P as ProductComponentContext, n as RealtimeMockupCallbacks, k as RealtimeMockupService, m as RealtimeMockupState, R as RenderResult, W as WebSocketConfig, l as WebSocketMessage, j as adapterRegistry, o as computeDisabledChoices, h as createComponent, i as defineComponent, p as deriveDefaultSelection, s as findBestCombination, q as getPricePreview, t as isOptionAvailable, r as resolveBestCombination } from './websocket-B8_XAwWx.js';
4
+
5
+ interface CatalogProduct$2 {
6
+ id: string;
7
+ name: string;
8
+ slug: string;
9
+ tags?: string[];
10
+ /**
11
+ * Price in minor units (cents)
12
+ */
13
+ price: number;
14
+ lowestPrice?: number;
15
+ highestPrice?: number;
16
+ mockups?: {
17
+ id: string;
18
+ ar: number;
19
+ gvids: string[];
20
+ }[];
21
+ options?: {
22
+ selected?: {
23
+ [k: string]: string | number | null;
24
+ };
25
+ attributes?: {
26
+ [k: string]: {
27
+ type?: string;
28
+ affectsCombinations?: boolean;
29
+ choices?: {
30
+ label: string;
31
+ hex?: string;
32
+ imageUrl?: string;
33
+ }[];
34
+ };
35
+ };
36
+ combinations?: {
37
+ price: number;
38
+ variantId: string;
39
+ }[];
40
+ attributesList?: string[];
41
+ };
42
+ care_guide?: string[];
43
+ description?: string[];
44
+ key_features?: string[];
45
+ days_to_deliver?: string | number;
46
+ size_chart_data?: {
47
+ [k: string]: unknown;
48
+ };
49
+ ships_from_country?: string;
50
+ variants?: {
51
+ gvid: string;
52
+ gvidForMockup?: string | null;
53
+ placements: {
54
+ label: string;
55
+ width: number | null;
56
+ height: number | null;
57
+ }[];
58
+ }[];
59
+ placements?: {
60
+ label: string;
61
+ type: 'image' | 'color';
62
+ width: number;
63
+ height: number;
64
+ defaultScaleMode?: 'fill' | 'fit';
65
+ fitMarginTop?: number;
66
+ fitMarginRight?: number;
67
+ fitMarginBottom?: number;
68
+ fitMarginLeft?: number;
69
+ fitAlign?: string;
70
+ align?: string;
71
+ scale?: number;
72
+ offsetX?: number;
73
+ offsetY?: number;
74
+ }[];
75
+ defaultGvid?: string;
76
+ }
77
+
78
+ /**
79
+ * Mockup service types and interfaces
80
+ */
81
+ type ImageAlignment$1 = "center" | "top" | "far-top" | "bottom" | "far-bottom" | "left" | "far-left" | "right" | "far-right";
82
+ type TileCount = 0.25 | 0.5 | 1 | 2 | 4;
83
+ interface ImageDesignElement {
84
+ type: "image";
85
+ imageUrl: string;
86
+ placement: string;
87
+ width: number;
88
+ height: number;
89
+ alignment: ImageAlignment$1;
90
+ tiles?: TileCount;
91
+ }
92
+ interface ColorDesignElement {
93
+ type: "color";
94
+ hex: string;
95
+ placement: string;
96
+ width: number;
97
+ height: number;
98
+ alignment: ImageAlignment$1;
99
+ imageUrl: "";
100
+ }
101
+ type DesignElement$1 = ImageDesignElement | ColorDesignElement;
102
+ interface ProductSpec {
103
+ productId: string;
104
+ mockupId: string;
105
+ variantId: string;
106
+ width: number;
107
+ optionSelections?: Record<string, string>;
108
+ }
109
+ interface Effects {
110
+ grain?: 1 | 2;
111
+ }
112
+ /** Supported aspect ratios */
113
+ type AspectRatio = '16:9' | '2:3';
114
+ /**
115
+ * Blend configuration for mockup masks
116
+ * Controls how artwork blends with the background texture
117
+ */
118
+ interface BlendConfig {
119
+ surface?: "glossy" | "matte" | "fabric" | "metal";
120
+ multiplyAlpha?: number;
121
+ multiplyContrast?: number;
122
+ highlightAlpha?: number;
123
+ highlightGamma?: number;
124
+ highlightSaturation?: number;
125
+ highlightBlend?: "add" | "screen" | "lighten" | "overlay";
126
+ colorBrightness?: number;
127
+ colorSaturation?: number;
128
+ }
129
+ /**
130
+ * Override configuration for a specific mask
131
+ * Use this for live preview/calibration of blend settings
132
+ */
133
+ interface MaskOverride {
134
+ id: string;
135
+ blendConfig?: BlendConfig;
136
+ }
137
+ interface GetMockupUrlOptions {
138
+ design: DesignElement$1[];
139
+ product: ProductSpec;
140
+ effects?: Effects;
141
+ /** Aspect ratio (default: '16:9') */
142
+ ar?: AspectRatio;
143
+ /** Mask overrides for live preview/calibration (not cached) */
144
+ maskOverrides?: MaskOverride[];
145
+ }
146
+ interface MockupServiceConfig {
147
+ imageUrl?: string;
148
+ signerUrl?: string;
149
+ accountId?: string;
150
+ }
151
+ interface MockupService {
152
+ getMockupUrl(options: GetMockupUrlOptions): Promise<string>;
153
+ getConfig(): MockupServiceConfig;
154
+ }
155
+ interface SignedUrlResponse {
156
+ url: string;
157
+ }
158
+ interface RateLimitState {
159
+ perMinute: {
160
+ count: number;
161
+ resetTime: number;
162
+ };
163
+ perSecond: {
164
+ count: number;
165
+ resetTime: number;
166
+ };
167
+ }
168
+
169
+ /**
170
+ * Framework-agnostic state management utilities
171
+ * Provides consistent state management patterns for React and Web Components
172
+ */
173
+ type StateUpdater<T> = T | ((prevState: T) => T);
174
+ type StateSubscriber<T> = (state: T, prevState?: T) => void;
175
+ type StateSelector<T, R> = (state: T) => R;
176
+ interface StateManagerOptions<T> {
177
+ initialState: T;
178
+ debug?: boolean;
179
+ persist?: {
180
+ key: string;
181
+ storage?: Storage;
182
+ };
183
+ middleware?: StateMiddleware<T>[];
184
+ }
185
+ interface StateMiddleware<T> {
186
+ name: string;
187
+ beforeUpdate?: (state: T, update: Partial<T>) => Partial<T>;
188
+ afterUpdate?: (state: T, prevState: T) => void;
189
+ }
190
+ /**
191
+ * Generic state manager that works across frameworks
192
+ */
193
+ declare class StateManager<T extends Record<string, any>> {
194
+ private options;
195
+ private state;
196
+ private prevState?;
197
+ private subscribers;
198
+ private selectorSubscribers;
199
+ private updateQueue;
200
+ private isUpdating;
201
+ private middleware;
202
+ constructor(options: StateManagerOptions<T>);
203
+ /**
204
+ * Get current state
205
+ */
206
+ getState(): T;
207
+ /**
208
+ * Update state with partial updates or updater function
209
+ */
210
+ setState(updater: StateUpdater<Partial<T>>): void;
211
+ /**
212
+ * Subscribe to all state changes
213
+ */
214
+ subscribe(callback: StateSubscriber<T>): () => void;
215
+ /**
216
+ * Subscribe to specific state selections (computed values)
217
+ */
218
+ subscribeToSelector<R>(selector: StateSelector<T, R>, callback: (value: R, prevValue?: R) => void): () => void;
219
+ /**
220
+ * Reset state to initial value
221
+ */
222
+ reset(): void;
223
+ /**
224
+ * Get a derived value from state
225
+ */
226
+ select<R>(selector: StateSelector<T, R>): R;
227
+ private processUpdateQueue;
228
+ private notifySubscribers;
229
+ private hasStateChanged;
230
+ private getStateDiff;
231
+ private persistState;
232
+ private loadPersistedState;
233
+ }
234
+ /**
235
+ * Create a simple state store
236
+ */
237
+ declare function createStateStore<T extends Record<string, any>>(initialState: T, options?: Omit<StateManagerOptions<T>, 'initialState'>): StateManager<T>;
238
+ /**
239
+ * Hook-like pattern for using state (works in any context)
240
+ */
241
+ declare function createStateHook<T extends Record<string, any>>(store: StateManager<T>): {
242
+ getState: () => T;
243
+ setState: (updater: StateUpdater<Partial<T>>) => void;
244
+ subscribe: (callback: StateSubscriber<T>) => () => void;
245
+ select: <R>(selector: StateSelector<T, R>) => R;
246
+ reset: () => void;
247
+ };
248
+
249
+ /**
250
+ * Base rendering descriptor types that all components can use
251
+ */
252
+ type TagName = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div';
253
+ interface BaseDescriptor {
254
+ type: string;
255
+ }
256
+ interface TextDescriptor extends BaseDescriptor {
257
+ type: 'text';
258
+ content: string;
259
+ tag: TagName;
260
+ className?: string;
261
+ }
262
+ interface ContainerDescriptor extends BaseDescriptor {
263
+ type: 'container';
264
+ children: Descriptor[];
265
+ tag: TagName;
266
+ className?: string;
267
+ }
268
+ type Descriptor = TextDescriptor | ContainerDescriptor;
269
+
270
+ interface ProductData {
271
+ name: string;
272
+ description?: string;
273
+ price: number;
274
+ category: string;
275
+ }
276
+ interface ProductTitleDescriptor {
277
+ type: "product-title";
278
+ product: ProductData;
279
+ showPrice?: boolean;
280
+ showDescription?: boolean;
281
+ size?: "sm" | "md" | "lg";
282
+ className?: string;
283
+ }
284
+ interface ProductTitleOptions {
285
+ product: ProductData;
286
+ showPrice?: boolean;
287
+ showDescription?: boolean;
288
+ size?: "sm" | "md" | "lg";
289
+ className?: string;
290
+ }
291
+ /**
292
+ * Creates a descriptor for rendering a product title component.
293
+ * This component displays product name, description, price, and category.
294
+ */
295
+ declare function describeProductTitle(options: ProductTitleOptions): ProductTitleDescriptor;
296
+
297
+ interface ProductPriceDescriptor extends BaseDescriptor {
298
+ type: 'price';
299
+ price: number;
300
+ currency: string;
301
+ locale: string;
302
+ showCurrency: boolean;
303
+ className?: string;
304
+ }
305
+ interface ProductPriceOptions {
306
+ price?: number;
307
+ currency?: string;
308
+ locale?: string;
309
+ showCurrency?: boolean;
310
+ className?: string;
311
+ }
312
+ /**
313
+ * Formats a price value for display
314
+ */
315
+ declare function formatPrice(cents: number, locale: string, currency: string, showCurrency: boolean): string;
316
+ /**
317
+ * Creates a descriptor for rendering a product price.
318
+ */
319
+ declare function describeProductPrice(options: ProductPriceOptions, contextPrice?: number): ProductPriceDescriptor | null;
320
+
321
+ interface ProductImageDescriptor extends BaseDescriptor {
322
+ type: 'image';
323
+ src: string;
324
+ alt: string;
325
+ width?: number;
326
+ height?: number;
327
+ aspectRatio?: string;
328
+ className?: string;
329
+ }
330
+ interface ProductImageOptions {
331
+ src?: string;
332
+ alt?: string;
333
+ width?: number;
334
+ height?: number;
335
+ aspectRatio?: string;
336
+ className?: string;
337
+ }
338
+ /**
339
+ * Creates a descriptor for rendering a product image.
340
+ */
341
+ declare function describeProductImage(options: ProductImageOptions, contextImage?: {
342
+ src?: string;
343
+ alt?: string;
344
+ }): ProductImageDescriptor | null;
345
+
346
+ interface ProductOptionChoice {
347
+ id: string;
348
+ name: string;
349
+ available: boolean;
350
+ color?: string;
351
+ price?: number;
352
+ }
353
+ interface ProductOptionData {
354
+ name: string;
355
+ type: "select" | "color" | "radio" | "checkbox";
356
+ required: boolean;
357
+ choices: ProductOptionChoice[];
358
+ }
359
+ interface ProductOptionsDescriptor {
360
+ type: "product-options";
361
+ options: ProductOptionData[];
362
+ selectedOptions: Record<string, string>;
363
+ className?: string;
364
+ }
365
+ interface ProductOptionsOptions {
366
+ options: ProductOptionData[];
367
+ selectedOptions?: Record<string, string>;
368
+ className?: string;
369
+ }
370
+ /**
371
+ * Creates a descriptor for rendering a product options component.
372
+ * This component allows users to select product variants like size, color, material, etc.
373
+ */
374
+ declare function describeProductOptions(options: ProductOptionsOptions): ProductOptionsDescriptor;
375
+
376
+ type ImageAlignment = "center" | "top" | "far-top" | "bottom" | "far-bottom" | "left" | "far-left" | "right" | "far-right";
377
+ interface ProductArtAlignmentDescriptor {
378
+ type: 'art-alignment';
379
+ src: string;
380
+ artworkAspectRatio: number;
381
+ maskAspectRatio: number;
382
+ effectiveAlignment: 'vertical' | 'horizontal';
383
+ alignment: ImageAlignment;
384
+ className?: string;
385
+ }
386
+ interface ProductArtAlignmentOptions {
387
+ src?: string;
388
+ artworkAspectRatio?: number;
389
+ maskAspectRatio?: number;
390
+ placement?: string;
391
+ alignment?: ImageAlignment;
392
+ className?: string;
393
+ }
394
+ interface ProductArtAlignmentContext {
395
+ product?: {
396
+ mockupUrl?: string;
397
+ aspectRatio?: number;
398
+ placements?: Array<{
399
+ label: string;
400
+ width: number;
401
+ height: number;
402
+ type?: 'image' | 'color';
403
+ }>;
404
+ };
405
+ selection?: {
406
+ alignment?: ImageAlignment;
407
+ };
408
+ }
409
+ /**
410
+ * Calculates the snap points for the mask based on container size and mask dimensions.
411
+ * Returns 3 snap points when aspect ratios are similar (limited movement space),
412
+ * or 5 snap points when there's significant movement space available.
413
+ */
414
+ declare function getSnapPoints(containerSize: {
415
+ width: number;
416
+ height: number;
417
+ }, maskDimensions: {
418
+ width: number;
419
+ height: number;
420
+ }, effectiveAlignment: 'horizontal' | 'vertical'): {
421
+ center: number;
422
+ 'far-left'?: undefined;
423
+ 'far-right'?: undefined;
424
+ left?: undefined;
425
+ right?: undefined;
426
+ 'far-top'?: undefined;
427
+ 'far-bottom'?: undefined;
428
+ top?: undefined;
429
+ bottom?: undefined;
430
+ } | {
431
+ 'far-left': number;
432
+ center: number;
433
+ 'far-right': number;
434
+ left?: undefined;
435
+ right?: undefined;
436
+ 'far-top'?: undefined;
437
+ 'far-bottom'?: undefined;
438
+ top?: undefined;
439
+ bottom?: undefined;
440
+ } | {
441
+ 'far-left': number;
442
+ left: number;
443
+ center: number;
444
+ right: number;
445
+ 'far-right': number;
446
+ 'far-top'?: undefined;
447
+ 'far-bottom'?: undefined;
448
+ top?: undefined;
449
+ bottom?: undefined;
450
+ } | {
451
+ 'far-top': number;
452
+ center: number;
453
+ 'far-bottom': number;
454
+ 'far-left'?: undefined;
455
+ 'far-right'?: undefined;
456
+ left?: undefined;
457
+ right?: undefined;
458
+ top?: undefined;
459
+ bottom?: undefined;
460
+ } | {
461
+ 'far-top': number;
462
+ top: number;
463
+ center: number;
464
+ bottom: number;
465
+ 'far-bottom': number;
466
+ 'far-left'?: undefined;
467
+ 'far-right'?: undefined;
468
+ left?: undefined;
469
+ right?: undefined;
470
+ };
471
+ /**
472
+ * Determines the effective alignment (horizontal or vertical) based on aspect ratios
473
+ */
474
+ declare function getEffectiveAlignment(artworkAspectRatio: number, maskAspectRatio: number): 'horizontal' | 'vertical';
475
+ /**
476
+ * Creates a descriptor for rendering a product art alignment component.
477
+ * This is the single source of truth for how product art alignment should be rendered.
478
+ */
479
+ declare function describeProductArtAlignment(options: ProductArtAlignmentOptions, context?: ProductArtAlignmentContext): ProductArtAlignmentDescriptor | null;
480
+ /**
481
+ * Finds the closest snap point for a given position
482
+ */
483
+ declare function findClosestSnapPoint(position: number, containerSize: {
484
+ width: number;
485
+ height: number;
486
+ }, maskDimensions: {
487
+ width: number;
488
+ height: number;
489
+ }, effectiveAlignment: 'horizontal' | 'vertical'): ImageAlignment;
490
+
491
+ type RegularArtwork = {
492
+ type: "regular";
493
+ src: string;
494
+ };
495
+ type SeamlessPattern = {
496
+ type: "pattern";
497
+ src: string;
498
+ tileCount: 0.25 | 0.5 | 1 | 2 | 4;
499
+ };
500
+ type ArtworkData = RegularArtwork | SeamlessPattern;
501
+ interface ArtSelectorDescriptor {
502
+ type: "art-selector";
503
+ artworks: ArtworkData[];
504
+ selectedArtwork: ArtworkData | null;
505
+ className?: string;
506
+ }
507
+ interface ArtSelectorOptions {
508
+ artworks?: string[];
509
+ className?: string;
510
+ }
511
+ interface ArtSelectorContext {
512
+ selectedArtwork?: ArtworkData;
513
+ }
514
+ /**
515
+ * Creates a descriptor for rendering an art selector component.
516
+ * This component allows users to select from a list of artwork images.
517
+ */
518
+ declare function describeArtSelector(options: ArtSelectorOptions, context?: ArtSelectorContext): ArtSelectorDescriptor;
519
+
520
+ /**
521
+ * Option selection rendering logic
522
+ * Shared between all framework implementations
523
+ */
524
+
525
+ interface OptionChoice {
526
+ label: string;
527
+ hex?: string;
528
+ imageUrl?: string;
529
+ value?: string;
530
+ }
531
+ interface OptionRenderData {
532
+ key: string;
533
+ label: string;
534
+ type: 'select' | 'color-picker' | 'swatch';
535
+ value: string;
536
+ choices: OptionChoiceRenderData[];
537
+ required: boolean;
538
+ }
539
+ interface OptionChoiceRenderData {
540
+ value: string;
541
+ label: string;
542
+ disabled: boolean;
543
+ selected: boolean;
544
+ hex?: string;
545
+ imageUrl?: string;
546
+ }
547
+ /**
548
+ * Determines the render type for an option attribute
549
+ */
550
+ declare function getOptionRenderType(attr: OptionAttribute): 'select' | 'color-picker' | 'swatch';
551
+ /**
552
+ * Normalizes a choice value to a consistent format
553
+ */
554
+ declare function normalizeChoice(choice: string | OptionChoice): OptionChoice;
555
+ /**
556
+ * Prepares option data for rendering
557
+ */
558
+ declare function prepareOptionRenderData(attributes: Record<string, OptionAttribute>, selection: OptionSelection, combinations: Combination[]): OptionRenderData[];
559
+ /**
560
+ * Handles option selection change
561
+ */
562
+ declare function handleOptionChange(optionKey: string, newValue: string, currentSelection: OptionSelection, attributes: Record<string, OptionAttribute>): OptionSelection;
563
+ /**
564
+ * Validates if all required options are selected
565
+ */
566
+ declare function validateRequiredOptions(selection: OptionSelection, attributes: Record<string, OptionAttribute>): {
567
+ valid: boolean;
568
+ missing: string[];
569
+ };
570
+ /**
571
+ * Gets display text for current selection
572
+ */
573
+ declare function getSelectionDisplayText(selection: OptionSelection, attributes: Record<string, OptionAttribute>): string;
574
+ /**
575
+ * Color picker specific utilities
576
+ */
577
+ declare const ColorPickerUtils: {
578
+ /**
579
+ * Validates a hex color
580
+ */
581
+ isValidHex(hex: string): boolean;
582
+ /**
583
+ * Converts hex to RGB
584
+ */
585
+ hexToRgb(hex: string): {
586
+ r: number;
587
+ g: number;
588
+ b: number;
589
+ } | null;
590
+ /**
591
+ * Gets contrast color for text on background
592
+ */
593
+ getContrastColor(hex: string): "white" | "black";
594
+ };
595
+ /**
596
+ * Swatch rendering utilities
597
+ */
598
+ declare const SwatchUtils: {
599
+ /**
600
+ * Gets swatch style object
601
+ */
602
+ getSwatchStyle(choice: OptionChoiceRenderData): Record<string, string>;
603
+ /**
604
+ * Gets swatch class names
605
+ */
606
+ getSwatchClasses(choice: OptionChoiceRenderData): string[];
607
+ };
608
+
609
+ /**
610
+ * Represents a design element for mockup generation
611
+ */
612
+ interface DesignElement {
613
+ type?: 'image' | 'color';
614
+ imageUrl?: string;
615
+ text?: string;
616
+ hex?: string;
617
+ placement?: string;
618
+ position?: {
619
+ x: number;
620
+ y: number;
621
+ };
622
+ size?: {
623
+ width: number;
624
+ height: number;
625
+ };
626
+ alignment?: ImageAlignment;
627
+ tiles?: 0.25 | 0.5 | 1 | 2 | 4;
628
+ width?: number;
629
+ height?: number;
630
+ }
631
+ /**
632
+ * Placement configuration from product data
633
+ */
634
+ interface Placement {
635
+ label: string;
636
+ type?: 'image' | 'color' | null;
637
+ width?: number;
638
+ height?: number;
639
+ }
640
+ /**
641
+ * Design configuration for a specific placement
642
+ */
643
+ interface PlacementDesign {
644
+ imageUrl?: string;
645
+ alignment?: ImageAlignment;
646
+ tiles?: 0.25 | 0.5 | 1 | 2 | 4;
647
+ }
648
+ /**
649
+ * Context for design generation
650
+ */
651
+ interface DesignGenerationContext {
652
+ selection?: Record<string, any>;
653
+ attributes?: Record<string, any>;
654
+ artworkSrc?: string;
655
+ placementDesigns?: Record<string, PlacementDesign>;
656
+ defaultImageUrl?: string;
657
+ tiles?: 0.25 | 0.5 | 1 | 2 | 4;
658
+ }
659
+
660
+ /**
661
+ * Default values for mockup generation
662
+ */
663
+ declare const DEFAULT_ARTWORK_URL = "https://images.unsplash.com/photo-1533738363-b7f9aef128ce?q=80&w=2670&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D";
664
+ declare const DEFAULT_COLOR = "#000000";
665
+ declare const DEFAULT_PLACEMENT_DIMENSIONS: {
666
+ width: number;
667
+ height: number;
668
+ };
669
+ declare const DEFAULT_ASPECT_RATIO = 1;
670
+
671
+ /**
672
+ * Creates design elements for each placement in a product.
673
+ * This is the single source of truth for how mockup designs are generated
674
+ * across both React and Web Component implementations.
675
+ *
676
+ * @param placements - Array of product placements
677
+ * @param providedImages - Optional array of pre-configured design elements
678
+ * @param context - Context containing selection, attributes, and other design data
679
+ * @returns Array of design elements ready for mockup generation
680
+ */
681
+ declare function createDesignForPlacements(placements: Placement[], providedImages?: DesignElement[], context?: DesignGenerationContext): DesignElement[];
682
+ /**
683
+ * Helper to filter image placements from all placements
684
+ * Handles both explicit 'image' type and null type (which defaults to image)
685
+ */
686
+ declare function filterImagePlacements(placements: Placement[]): Placement[];
687
+
688
+ /**
689
+ * Shared mockup URL generation logic for both React and Web Components
690
+ */
691
+
692
+ interface MockupConfig {
693
+ endpoint?: string;
694
+ mockupUrl?: string;
695
+ signerUrl?: string;
696
+ accountId?: string;
697
+ mode?: "mock" | "live";
698
+ }
699
+
700
+ interface MockupGenerationOptions {
701
+ productId: string;
702
+ mockupId: string;
703
+ variantId: string;
704
+ design: DesignElement[];
705
+ width: number;
706
+ effects?: {
707
+ grain?: 1 | 2;
708
+ };
709
+ /** Aspect ratio (default: '16:9') */
710
+ ar?: AspectRatio;
711
+ /** Mask overrides for live preview/calibration (not cached) */
712
+ maskOverrides?: MaskOverride[];
713
+ }
714
+
715
+ /**
716
+ * User's selected product options
717
+ * Keys are attribute names (Size, Color, Material, etc.)
718
+ * Values are the selected option values
719
+ */
720
+ type UserSelection = Record<string, string>;
721
+ declare function config(overrides?: MockupConfig): MockupConfig;
722
+ /**
723
+ * @deprecated Use `config` instead
724
+ */
725
+ declare const resolveMockupConfig: typeof config;
726
+ /**
727
+ * Creates a mockup URL from the provided options
728
+ * Uses configuration from config() which reads from environment/window
729
+ */
730
+ declare function mockupUrl(options: MockupGenerationOptions): string;
731
+ /**
732
+ * SDK-friendly helper to get variant details from selected options
733
+ * @param selection User's selected options (e.g. { Size: 'L', Color: 'Blue' })
734
+ * @param product Product data from API including combinations, mockups, attributes
735
+ * @returns Object with variantId, mockupId, price, and the full combination
736
+ */
737
+ declare function getVariant(selection: UserSelection, product: {
738
+ combinations: Array<{
739
+ variantId: string;
740
+ price?: number;
741
+ [key: string]: any;
742
+ }>;
743
+ mockups: Array<{
744
+ id: string;
745
+ gvids?: string[];
746
+ }>;
747
+ attributes?: Record<string, any>;
748
+ }): {
749
+ variantId: string | undefined;
750
+ mockupId: string | undefined;
751
+ price: number | undefined;
752
+ combination: any | undefined;
753
+ };
754
+ /**
755
+ * Internal helper - determines the variant ID based on context and fallbacks
756
+ * Used by React/Vue/WC components that have context
757
+ */
758
+ declare function resolveVariantId(context: any, providedGvid?: string, providedVariantId?: string): string;
759
+ /**
760
+ * Internal helper - determines the mockup ID based on variant and available mockups
761
+ * Used by React/Vue/WC components that have context
762
+ */
763
+ declare function resolveMockupId(context: any, variantId: string, providedMockupId?: string): string | null;
764
+
765
+ /**
766
+ * Product data transformation utilities
767
+ * Converts catalog product data to component-friendly formats
768
+ */
769
+ type CatalogProduct$1 = any;
770
+
771
+ /**
772
+ * Transforms product options attributes into the standard OptionAttribute format
773
+ * @param product - The catalog product from the API
774
+ * @returns Normalized option attributes with choice objects
775
+ */
776
+ declare function toOptionAttributes(product?: CatalogProduct$1): Record<string, OptionAttribute>;
777
+ /**
778
+ * Extracts combinations from product options
779
+ * @param product - The catalog product from the API
780
+ * @returns Array of valid combinations
781
+ */
782
+ declare function toCombinations(product?: CatalogProduct$1): Combination[];
783
+ /**
784
+ * Extracts product ID from various possible locations in the product data
785
+ * @param product - The catalog product from the API
786
+ * @returns The product ID or undefined
787
+ */
788
+ declare function extractProductId(product?: CatalogProduct$1): string | undefined;
789
+ /**
790
+ * Gets the default variant ID for a product
791
+ * @param product - The catalog product from the API
792
+ * @returns The default variant ID or 'default' as fallback
793
+ */
794
+ declare function getDefaultVariantId(product?: CatalogProduct$1): string;
795
+
796
+ /**
797
+ * Product selection validation utilities
798
+ * Ensures selections are complete and valid before cart operations
799
+ */
800
+
801
+ /**
802
+ * Validates that a product selection is complete and valid
803
+ * @param attributes - Product option attributes
804
+ * @param selection - Current user selection
805
+ * @param combinations - Valid product combinations
806
+ * @returns true if selection is valid and complete
807
+ */
808
+ declare function validateProductSelection(attributes: Record<string, OptionAttribute>, selection: OptionSelection, combinations: Combination[]): boolean;
809
+ /**
810
+ * Gets the list of missing required selections
811
+ * @param attributes - Product option attributes
812
+ * @param selection - Current user selection
813
+ * @returns Array of attribute keys that are required but not selected
814
+ */
815
+ declare function getMissingSelections(attributes: Record<string, OptionAttribute>, selection: OptionSelection): string[];
816
+ /**
817
+ * Checks if a selection is complete (all required options selected)
818
+ * @param attributes - Product option attributes
819
+ * @param selection - Current user selection
820
+ * @returns true if all required options are selected
821
+ */
822
+ declare function isSelectionComplete(attributes: Record<string, OptionAttribute>, selection: OptionSelection): boolean;
823
+ /**
824
+ * Creates a user-friendly message for incomplete selections
825
+ * @param attributes - Product option attributes
826
+ * @param selection - Current user selection
827
+ * @returns A message describing what needs to be selected
828
+ */
829
+ declare function getIncompleteSelectionMessage(attributes: Record<string, OptionAttribute>, selection: OptionSelection): string;
830
+
831
+ /**
832
+ * Validation functions for mockup generation parameters
833
+ */
834
+
835
+ interface ValidationError {
836
+ field: string;
837
+ message: string;
838
+ value?: any;
839
+ }
840
+ interface ValidationResult {
841
+ valid: boolean;
842
+ errors: ValidationError[];
843
+ }
844
+ /**
845
+ * Validates an image URL
846
+ * NOTE: Relative URLs are now accepted and will be normalized to absolute URLs
847
+ * by the design generation layer before reaching the mockup API.
848
+ */
849
+ declare function validateImageUrl(url: string): ValidationResult;
850
+ /**
851
+ * Validates alignment value
852
+ */
853
+ declare function validateAlignment(alignment: string): ValidationResult;
854
+ /**
855
+ * Validates tile count
856
+ */
857
+ declare function validateTileCount(tiles: number): ValidationResult;
858
+ /**
859
+ * Validates a design element
860
+ */
861
+ declare function validateDesignElement(element: DesignElement$1): ValidationResult;
862
+ /**
863
+ * Validates product specification
864
+ */
865
+ declare function validateProductSpec(spec: ProductSpec): ValidationResult;
866
+ /**
867
+ * Validates visual effects
868
+ */
869
+ declare function validateEffects(effects: Effects): ValidationResult;
870
+ /**
871
+ * Validates complete mockup URL options
872
+ */
873
+ declare function validateMockupOptions(options: GetMockupUrlOptions): ValidationResult;
874
+ /**
875
+ * Helper function to format validation errors as a string
876
+ */
877
+ declare function formatValidationErrors(errors: ValidationError[]): string;
878
+ /**
879
+ * Type guard to check if a value is a valid ImageAlignment
880
+ */
881
+ declare function isValidAlignment(value: string): value is ImageAlignment$1;
882
+ /**
883
+ * Type guard to check if a value is a valid TileCount
884
+ */
885
+ declare function isValidTileCount(value: number): value is TileCount;
886
+
887
+ /**
888
+ * Cart operation utilities
889
+ * Shared logic for adding items to cart across implementations
890
+ */
891
+
892
+ interface CartDetail {
893
+ productId: string;
894
+ variantId?: string;
895
+ quantity: number;
896
+ selection: OptionSelection;
897
+ price?: number;
898
+ attributes?: Record<string, any>;
899
+ }
900
+ interface AddToCartOptions {
901
+ productId: string;
902
+ quantity?: number;
903
+ selection: OptionSelection;
904
+ combinations: Combination[];
905
+ attributes: Record<string, OptionAttribute>;
906
+ }
907
+ /**
908
+ * Creates cart detail object from selection
909
+ * @param options - Options for creating cart detail
910
+ * @returns Cart detail object ready for submission
911
+ */
912
+ declare function createCartDetail(options: AddToCartOptions): CartDetail | null;
913
+ /**
914
+ * Finds the variant for a given selection
915
+ * @param selection - Current selection
916
+ * @param combinations - Available combinations
917
+ * @param attributes - Product attributes
918
+ * @returns The variant ID or undefined
919
+ */
920
+ declare function findVariantForSelection(selection: OptionSelection, combinations: Combination[], attributes: Record<string, OptionAttribute>): string | undefined;
921
+ /**
922
+ * Creates an add to cart event detail
923
+ * @param cartDetail - The cart detail object
924
+ * @returns Event detail for cart addition
925
+ */
926
+ declare function createAddToCartEvent(cartDetail: CartDetail): {
927
+ detail: {
928
+ productId: string;
929
+ variantId: string | undefined;
930
+ quantity: number;
931
+ selection: OptionSelection;
932
+ price: number | undefined;
933
+ timestamp: number;
934
+ };
935
+ bubbles: boolean;
936
+ composed: boolean;
937
+ cancelable: boolean;
938
+ };
939
+ /**
940
+ * Simulates adding to cart with loading state
941
+ * @param duration - Duration of simulated operation in ms
942
+ * @returns Promise that resolves after duration
943
+ */
944
+ declare function simulateCartOperation(duration?: number): Promise<void>;
945
+ /**
946
+ * Creates a handler function for add to cart operations
947
+ * @param options - Configuration for the handler
948
+ * @returns Handler function
949
+ */
950
+ declare function createAddToCartHandler(options: {
951
+ onValidate?: () => boolean;
952
+ onStart?: () => void;
953
+ onSuccess?: (detail: CartDetail) => void;
954
+ onError?: (error: Error) => void;
955
+ simulateDelay?: number;
956
+ }): (productId: string, selection: OptionSelection, combinations: Combination[], attributes: Record<string, OptionAttribute>, quantity?: number) => Promise<CartDetail | null>;
957
+
958
+ /**
959
+ * Shared error handling utilities for consistent error management
960
+ * across React and Web Component implementations
961
+ */
962
+ interface ErrorContext {
963
+ component: string;
964
+ operation: string;
965
+ retryable?: boolean;
966
+ userMessage?: string;
967
+ metadata?: Record<string, any>;
968
+ }
969
+ interface ErrorHandler {
970
+ handle: (error: Error) => void;
971
+ handleAsync: (error: Error) => Promise<void>;
972
+ clear: () => void;
973
+ getLastError: () => Error | null;
974
+ canRetry: () => boolean;
975
+ }
976
+ declare class ErrorManager {
977
+ private context;
978
+ private onError?;
979
+ private onClear?;
980
+ private lastError;
981
+ private errorCount;
982
+ private readonly maxRetries;
983
+ constructor(context: ErrorContext, onError?: ((error: Error, context: ErrorContext) => void) | undefined, onClear?: (() => void) | undefined);
984
+ handle(error: Error): void;
985
+ handleAsync(error: Error): Promise<void>;
986
+ clear(): void;
987
+ getLastError(): Error | null;
988
+ canRetry(): boolean;
989
+ getUserMessage(): string;
990
+ }
991
+ /**
992
+ * Creates an error handler with standard configuration
993
+ */
994
+ declare function createErrorHandler(context: ErrorContext, callbacks?: {
995
+ onError?: (error: Error, context: ErrorContext) => void;
996
+ onClear?: () => void;
997
+ }): ErrorHandler;
998
+ /**
999
+ * Wraps an async operation with error handling
1000
+ */
1001
+ declare function withErrorHandling<T>(operation: () => Promise<T>, errorHandler: ErrorHandler, options?: {
1002
+ retry?: boolean;
1003
+ retryDelay?: number;
1004
+ fallback?: T;
1005
+ }): Promise<T | null>;
1006
+ /**
1007
+ * Wraps a synchronous operation with error handling
1008
+ */
1009
+ declare function withSyncErrorHandling<T>(operation: () => T, errorHandler: ErrorHandler, fallback?: T): T | null;
1010
+ /**
1011
+ * Creates a retry mechanism for operations
1012
+ */
1013
+ declare function retryOperation<T>(operation: () => Promise<T>, options?: {
1014
+ maxAttempts?: number;
1015
+ delay?: number;
1016
+ backoff?: boolean;
1017
+ onRetry?: (attempt: number, error: Error) => void;
1018
+ }): Promise<T>;
1019
+
1020
+ /**
1021
+ * Context synchronization utilities for managing state updates
1022
+ * across React and Web Component implementations
1023
+ */
1024
+ interface ContextSubscriber<T> {
1025
+ (context: T, previousContext?: T): void;
1026
+ }
1027
+ interface ContextComparator<T> {
1028
+ (prev: T, next: T): boolean;
1029
+ }
1030
+ /**
1031
+ * Manages context synchronization with batching and change detection
1032
+ */
1033
+ declare class ContextSynchronizer<T> {
1034
+ private options;
1035
+ private subscribers;
1036
+ private currentContext?;
1037
+ private previousContext?;
1038
+ private updateTimer?;
1039
+ private pendingUpdate?;
1040
+ private readonly batchDelay;
1041
+ constructor(options?: {
1042
+ batchDelay?: number;
1043
+ comparator?: ContextComparator<T>;
1044
+ onUpdate?: (context: T) => void;
1045
+ debug?: boolean;
1046
+ });
1047
+ /**
1048
+ * Subscribe to context changes
1049
+ */
1050
+ subscribe(callback: ContextSubscriber<T>): () => void;
1051
+ /**
1052
+ * Update context with optional batching
1053
+ */
1054
+ updateContext(context: T): void;
1055
+ /**
1056
+ * Force immediate context update (bypasses batching)
1057
+ */
1058
+ forceUpdate(context: T): void;
1059
+ /**
1060
+ * Get current context
1061
+ */
1062
+ getContext(): T | undefined;
1063
+ /**
1064
+ * Clear all subscribers
1065
+ */
1066
+ clear(): void;
1067
+ private hasContextChanged;
1068
+ private scheduleBatchedUpdate;
1069
+ private clearPendingUpdate;
1070
+ private applyContextUpdate;
1071
+ private deepEqual;
1072
+ }
1073
+ /**
1074
+ * Creates a context bridge between different component systems
1075
+ */
1076
+ declare class ContextBridge<T> {
1077
+ private synchronizers;
1078
+ /**
1079
+ * Register a synchronizer with a key
1080
+ */
1081
+ register(key: string, synchronizer: ContextSynchronizer<T>): void;
1082
+ /**
1083
+ * Bridge context updates between synchronizers
1084
+ */
1085
+ bridge(fromKey: string, toKey: string): () => void;
1086
+ /**
1087
+ * Broadcast context to all registered synchronizers
1088
+ */
1089
+ broadcast(context: T, excludeKey?: string): void;
1090
+ }
1091
+ /**
1092
+ * Helper to create a context provider pattern
1093
+ */
1094
+ declare function createContextProvider<T>(initialContext?: T, options?: {
1095
+ batchDelay?: number;
1096
+ debug?: boolean;
1097
+ }): {
1098
+ subscribe: (callback: ContextSubscriber<T>) => () => void;
1099
+ update: (context: T) => void;
1100
+ get: () => T | undefined;
1101
+ clear: () => void;
1102
+ };
1103
+
1104
+ /**
1105
+ * Unified event system for cross-framework components
1106
+ * Provides consistent event handling across React, Vue, Svelte, etc.
1107
+ */
1108
+ interface EventDefinition {
1109
+ name: string;
1110
+ bubbles?: boolean;
1111
+ cancelable?: boolean;
1112
+ composed?: boolean;
1113
+ passive?: boolean;
1114
+ }
1115
+ interface EventPayload<T = any> {
1116
+ detail?: T;
1117
+ target?: any;
1118
+ currentTarget?: any;
1119
+ timestamp?: number;
1120
+ [key: string]: any;
1121
+ }
1122
+ type EventListener<T = any> = (event: EventPayload<T>) => void;
1123
+ /**
1124
+ * Cross-framework event emitter
1125
+ */
1126
+ declare class EventEmitter {
1127
+ private listeners;
1128
+ private onceListeners;
1129
+ /**
1130
+ * Add event listener
1131
+ */
1132
+ on(event: string, listener: EventListener): () => void;
1133
+ /**
1134
+ * Add one-time event listener
1135
+ */
1136
+ once(event: string, listener: EventListener): () => void;
1137
+ /**
1138
+ * Remove event listener
1139
+ */
1140
+ off(event: string, listener: EventListener): void;
1141
+ /**
1142
+ * Emit event
1143
+ */
1144
+ emit<T = any>(event: string, payload?: EventPayload<T>): boolean;
1145
+ /**
1146
+ * Remove all listeners for an event
1147
+ */
1148
+ removeAllListeners(event?: string): void;
1149
+ /**
1150
+ * Get listener count
1151
+ */
1152
+ listenerCount(event: string): number;
1153
+ }
1154
+ /**
1155
+ * Event manager for components
1156
+ */
1157
+ declare class ComponentEventManager {
1158
+ private emitter;
1159
+ private definitions;
1160
+ private element?;
1161
+ constructor(element?: HTMLElement);
1162
+ /**
1163
+ * Define an event
1164
+ */
1165
+ define(definition: EventDefinition): void;
1166
+ /**
1167
+ * Emit an event (works for both DOM and synthetic events)
1168
+ */
1169
+ emit<T = any>(name: string, detail?: T): boolean;
1170
+ /**
1171
+ * Listen to an event
1172
+ */
1173
+ on(event: string, listener: EventListener): () => void;
1174
+ /**
1175
+ * Listen to an event once
1176
+ */
1177
+ once(event: string, listener: EventListener): () => void;
1178
+ /**
1179
+ * Remove listener
1180
+ */
1181
+ off(event: string, listener: EventListener): void;
1182
+ /**
1183
+ * Set DOM element for event dispatching
1184
+ */
1185
+ setElement(element: HTMLElement): void;
1186
+ /**
1187
+ * Get all defined events
1188
+ */
1189
+ getDefinitions(): EventDefinition[];
1190
+ }
1191
+ /**
1192
+ * Standard component events
1193
+ */
1194
+ declare const StandardEvents: {
1195
+ readonly mounted: {
1196
+ readonly name: "mounted";
1197
+ readonly bubbles: false;
1198
+ };
1199
+ readonly unmounted: {
1200
+ readonly name: "unmounted";
1201
+ readonly bubbles: false;
1202
+ };
1203
+ readonly updated: {
1204
+ readonly name: "updated";
1205
+ readonly bubbles: false;
1206
+ };
1207
+ readonly change: {
1208
+ readonly name: "change";
1209
+ readonly bubbles: true;
1210
+ };
1211
+ readonly input: {
1212
+ readonly name: "input";
1213
+ readonly bubbles: true;
1214
+ };
1215
+ readonly click: {
1216
+ readonly name: "click";
1217
+ readonly bubbles: true;
1218
+ };
1219
+ readonly focus: {
1220
+ readonly name: "focus";
1221
+ readonly bubbles: false;
1222
+ };
1223
+ readonly blur: {
1224
+ readonly name: "blur";
1225
+ readonly bubbles: false;
1226
+ };
1227
+ readonly selectionChange: {
1228
+ readonly name: "selection-change";
1229
+ readonly bubbles: true;
1230
+ };
1231
+ readonly priceUpdate: {
1232
+ readonly name: "price-update";
1233
+ readonly bubbles: true;
1234
+ };
1235
+ readonly addToCart: {
1236
+ readonly name: "add-to-cart";
1237
+ readonly bubbles: true;
1238
+ };
1239
+ readonly variantChange: {
1240
+ readonly name: "variant-change";
1241
+ readonly bubbles: true;
1242
+ };
1243
+ readonly contextRequest: {
1244
+ readonly name: "context-request";
1245
+ readonly bubbles: true;
1246
+ };
1247
+ readonly contextProvide: {
1248
+ readonly name: "context-provide";
1249
+ readonly bubbles: false;
1250
+ };
1251
+ readonly contextUpdate: {
1252
+ readonly name: "context-update";
1253
+ readonly bubbles: true;
1254
+ };
1255
+ };
1256
+ /**
1257
+ * Event delegation helper for efficient event handling
1258
+ */
1259
+ declare class EventDelegator {
1260
+ private element;
1261
+ private handlers;
1262
+ constructor(element: HTMLElement);
1263
+ /**
1264
+ * Add delegated event listener
1265
+ */
1266
+ delegate(eventType: string, selector: string, handler: EventListener): () => void;
1267
+ /**
1268
+ * Remove all delegated listeners
1269
+ */
1270
+ destroy(): void;
1271
+ }
1272
+ /**
1273
+ * Create event manager for a component
1274
+ */
1275
+ declare function createEventManager(element?: HTMLElement): ComponentEventManager;
1276
+
1277
+ /**
1278
+ * Product context management
1279
+ * Framework-agnostic product state and context handling
1280
+ */
1281
+
1282
+ type CatalogProduct = any;
1283
+ /**
1284
+ * Product context interface
1285
+ */
1286
+ interface ProductContext {
1287
+ product?: CatalogProduct;
1288
+ optionAttributes: Record<string, OptionAttribute>;
1289
+ combinations: Combination[];
1290
+ selection: OptionSelection;
1291
+ loading?: boolean;
1292
+ error?: any;
1293
+ }
1294
+ /**
1295
+ * Product context events
1296
+ */
1297
+ interface ProductContextEvents {
1298
+ 'context-update': ProductContext;
1299
+ 'selection-change': OptionSelection;
1300
+ 'product-load': CatalogProduct;
1301
+ 'product-error': Error;
1302
+ 'loading-change': boolean;
1303
+ }
1304
+ /**
1305
+ * Product context manager
1306
+ */
1307
+ declare class ProductContextManager extends EventEmitter {
1308
+ private context;
1309
+ private updateQueue;
1310
+ private updateTimer;
1311
+ /**
1312
+ * Get current context
1313
+ */
1314
+ getContext(): ProductContext;
1315
+ /**
1316
+ * Set product data
1317
+ */
1318
+ setProduct(product: CatalogProduct | undefined): void;
1319
+ /**
1320
+ * Update selection
1321
+ */
1322
+ updateSelection(selection: OptionSelection): void;
1323
+ /**
1324
+ * Set loading state
1325
+ */
1326
+ setLoading(loading: boolean): void;
1327
+ /**
1328
+ * Set error state
1329
+ */
1330
+ setError(error: any): void;
1331
+ /**
1332
+ * Update context with batching
1333
+ */
1334
+ private updateContext;
1335
+ /**
1336
+ * Process batched updates
1337
+ */
1338
+ private processBatchUpdate;
1339
+ /**
1340
+ * Derive complete selection
1341
+ */
1342
+ private deriveSelection;
1343
+ /**
1344
+ * Subscribe to context updates
1345
+ */
1346
+ subscribe(callback: (context: ProductContext) => void): () => void;
1347
+ /**
1348
+ * Reset context
1349
+ */
1350
+ reset(): void;
1351
+ }
1352
+ /**
1353
+ * Create a product context manager
1354
+ */
1355
+ declare function createProductContext(): ProductContextManager;
1356
+ /**
1357
+ * Product fetcher interface
1358
+ */
1359
+ interface ProductFetcher {
1360
+ getProduct(productId: string, options?: any): Promise<CatalogProduct>;
1361
+ listProducts(options?: any): Promise<{
1362
+ items: CatalogProduct[];
1363
+ }>;
1364
+ }
1365
+ /**
1366
+ * Product loader with fetching capabilities
1367
+ */
1368
+ declare class ProductLoader {
1369
+ private context;
1370
+ private fetcher?;
1371
+ private cache;
1372
+ private currentRequest?;
1373
+ constructor(context: ProductContextManager, fetcher?: ProductFetcher);
1374
+ /**
1375
+ * Load product by ID
1376
+ */
1377
+ loadProduct(productId: string, options?: any): Promise<void>;
1378
+ /**
1379
+ * Fetch product
1380
+ */
1381
+ private fetchProduct;
1382
+ /**
1383
+ * Load first available product
1384
+ */
1385
+ loadFirstProduct(options?: any): Promise<void>;
1386
+ /**
1387
+ * Clear cache
1388
+ */
1389
+ clearCache(): void;
1390
+ /**
1391
+ * Set fetcher
1392
+ */
1393
+ setFetcher(fetcher: ProductFetcher): void;
1394
+ }
1395
+ /**
1396
+ * Create a product loader
1397
+ */
1398
+ declare function createProductLoader(context: ProductContextManager, fetcher?: ProductFetcher): ProductLoader;
1399
+
1400
+ /**
1401
+ * Unified context provider pattern
1402
+ * Framework-agnostic context management
1403
+ */
1404
+
1405
+ /**
1406
+ * Context provider configuration
1407
+ */
1408
+ interface ContextProviderConfig {
1409
+ mode?: 'mock' | 'live' | 'meilisearch';
1410
+ endpoint?: string;
1411
+ productId?: string;
1412
+ autoLoad?: boolean;
1413
+ fetcher?: any;
1414
+ }
1415
+ /**
1416
+ * Context consumer interface
1417
+ */
1418
+ interface ContextConsumer<T = ProductContext> {
1419
+ onContextUpdate(context: T): void;
1420
+ onContextError?(error: any): void;
1421
+ onContextLoading?(loading: boolean): void;
1422
+ }
1423
+ /**
1424
+ * Universal context provider
1425
+ * Works across React, Vue, Svelte, Web Components
1426
+ */
1427
+ declare class UniversalContextProvider extends EventEmitter {
1428
+ private contextManager;
1429
+ private loader;
1430
+ private config;
1431
+ private consumers;
1432
+ private initialized;
1433
+ constructor(config?: ContextProviderConfig);
1434
+ /**
1435
+ * Initialize the provider
1436
+ */
1437
+ initialize(): Promise<void>;
1438
+ /**
1439
+ * Load product data
1440
+ */
1441
+ loadProduct(productId?: string): Promise<void>;
1442
+ /**
1443
+ * Get current context
1444
+ */
1445
+ getContext(): ProductContext;
1446
+ /**
1447
+ * Update selection
1448
+ */
1449
+ updateSelection(selection: Record<string, string>): void;
1450
+ /**
1451
+ * Register a consumer
1452
+ */
1453
+ registerConsumer(consumer: ContextConsumer): () => void;
1454
+ /**
1455
+ * Setup internal subscriptions
1456
+ */
1457
+ private setupSubscriptions;
1458
+ /**
1459
+ * Destroy the provider
1460
+ */
1461
+ destroy(): void;
1462
+ }
1463
+ /**
1464
+ * Context injection patterns for different frameworks
1465
+ */
1466
+ declare class ContextInjector {
1467
+ /**
1468
+ * React context injection
1469
+ */
1470
+ static forReact(provider: UniversalContextProvider): any;
1471
+ /**
1472
+ * Vue context injection
1473
+ */
1474
+ static forVue(provider: UniversalContextProvider): any;
1475
+ /**
1476
+ * Svelte context injection
1477
+ */
1478
+ static forSvelte(provider: UniversalContextProvider): any;
1479
+ /**
1480
+ * Web Components context injection
1481
+ */
1482
+ static forWebComponents(provider: UniversalContextProvider): any;
1483
+ }
1484
+ /**
1485
+ * Create a universal context provider
1486
+ */
1487
+ declare function createUniversalProvider(config?: ContextProviderConfig): UniversalContextProvider;
1488
+ /**
1489
+ * HOC/Mixin for consuming context
1490
+ */
1491
+ declare function withContext<T extends new (...args: any[]) => any>(Base: T): {
1492
+ new (...args: any[]): {
1493
+ [x: string]: any;
1494
+ context?: ProductContext;
1495
+ contextUnsubscribe?: () => void;
1496
+ connectedCallback(): void;
1497
+ disconnectedCallback(): void;
1498
+ onContextUpdate(context: ProductContext): void;
1499
+ onContextError(error: any): void;
1500
+ onContextLoading(loading: boolean): void;
1501
+ findProvider(): UniversalContextProvider | undefined;
1502
+ };
1503
+ } & T;
1504
+
1505
+ /**
1506
+ * DOM manipulation utilities
1507
+ * Shared across all framework implementations
1508
+ */
1509
+ /**
1510
+ * Class name utilities
1511
+ */
1512
+ declare const ClassNames: {
1513
+ /**
1514
+ * Combine class names conditionally
1515
+ */
1516
+ combine(...args: (string | undefined | false | null | Record<string, boolean>)[]): string;
1517
+ /**
1518
+ * Toggle a class on an element
1519
+ */
1520
+ toggle(element: HTMLElement, className: string, force?: boolean): void;
1521
+ /**
1522
+ * Add classes with prefix
1523
+ */
1524
+ withPrefix(prefix: string, ...suffixes: string[]): string;
1525
+ };
1526
+ /**
1527
+ * Style utilities
1528
+ */
1529
+ declare const Styles: {
1530
+ /**
1531
+ * Merge style objects
1532
+ */
1533
+ merge(...styles: (Record<string, any> | undefined)[]): Record<string, any>;
1534
+ /**
1535
+ * Convert style object to CSS string
1536
+ */
1537
+ toCss(style: Record<string, any>): string;
1538
+ /**
1539
+ * Parse CSS string to style object
1540
+ */
1541
+ fromCss(css: string): Record<string, string>;
1542
+ };
1543
+ /**
1544
+ * Attribute utilities
1545
+ */
1546
+ declare const Attributes: {
1547
+ /**
1548
+ * Set attributes on an element
1549
+ */
1550
+ set(element: HTMLElement, attributes: Record<string, any>): void;
1551
+ /**
1552
+ * Get all attributes as an object
1553
+ */
1554
+ getAll(element: HTMLElement): Record<string, string>;
1555
+ /**
1556
+ * Parse JSON attribute safely
1557
+ */
1558
+ parseJson<T>(element: HTMLElement, attributeName: string, defaultValue: T): T;
1559
+ };
1560
+ /**
1561
+ * Element creation utilities
1562
+ */
1563
+ declare const Elements: {
1564
+ /**
1565
+ * Create element with properties
1566
+ */
1567
+ create<K extends keyof HTMLElementTagNameMap>(tag: K, props?: {
1568
+ className?: string;
1569
+ style?: Record<string, any>;
1570
+ attributes?: Record<string, any>;
1571
+ children?: (Node | string)[];
1572
+ text?: string;
1573
+ html?: string;
1574
+ }): HTMLElementTagNameMap[K];
1575
+ /**
1576
+ * Create fragment with children
1577
+ */
1578
+ fragment(...children: (Node | string)[]): DocumentFragment;
1579
+ /**
1580
+ * Replace element's children
1581
+ */
1582
+ replaceChildren(element: HTMLElement, ...children: (Node | string)[]): void;
1583
+ };
1584
+ /**
1585
+ * Focus management utilities
1586
+ */
1587
+ declare const Focus: {
1588
+ /**
1589
+ * Trap focus within an element
1590
+ */
1591
+ trap(container: HTMLElement): () => void;
1592
+ /**
1593
+ * Restore focus to previous element
1594
+ */
1595
+ restore(previousElement?: HTMLElement): void;
1596
+ };
1597
+ /**
1598
+ * Animation utilities
1599
+ */
1600
+ declare const Animations: {
1601
+ /**
1602
+ * Fade in element
1603
+ */
1604
+ fadeIn(element: HTMLElement, duration?: number): Promise<void>;
1605
+ /**
1606
+ * Fade out element
1607
+ */
1608
+ fadeOut(element: HTMLElement, duration?: number): Promise<void>;
1609
+ /**
1610
+ * Slide toggle
1611
+ */
1612
+ slideToggle(element: HTMLElement, duration?: number): Promise<void>;
1613
+ };
1614
+
1615
+ /**
1616
+ * Component lifecycle management
1617
+ * Provides unified lifecycle handling across frameworks
1618
+ */
1619
+ type LifecyclePhase = 'created' | 'mounting' | 'mounted' | 'updating' | 'updated' | 'unmounting' | 'unmounted' | 'error';
1620
+ interface LifecycleHook {
1621
+ phase: LifecyclePhase;
1622
+ handler: (context?: any) => void | Promise<void>;
1623
+ priority?: number;
1624
+ }
1625
+ interface LifecycleTransition {
1626
+ from: LifecyclePhase;
1627
+ to: LifecyclePhase;
1628
+ timestamp: number;
1629
+ duration?: number;
1630
+ }
1631
+ /**
1632
+ * Manages component lifecycle across different frameworks
1633
+ */
1634
+ declare class LifecycleManager {
1635
+ private currentPhase;
1636
+ private hooks;
1637
+ private transitions;
1638
+ private listeners;
1639
+ /**
1640
+ * Register a lifecycle hook
1641
+ */
1642
+ addHook(hook: LifecycleHook): () => void;
1643
+ /**
1644
+ * Transition to a new lifecycle phase
1645
+ */
1646
+ transitionTo(phase: LifecyclePhase, context?: any): Promise<void>;
1647
+ /**
1648
+ * Get current lifecycle phase
1649
+ */
1650
+ getPhase(): LifecyclePhase;
1651
+ /**
1652
+ * Subscribe to lifecycle changes
1653
+ */
1654
+ subscribe(listener: (phase: LifecyclePhase) => void): () => void;
1655
+ /**
1656
+ * Get lifecycle history
1657
+ */
1658
+ getHistory(): LifecycleTransition[];
1659
+ /**
1660
+ * Reset lifecycle state
1661
+ */
1662
+ reset(): void;
1663
+ }
1664
+ /**
1665
+ * Standard component lifecycle flow
1666
+ */
1667
+ declare class ComponentLifecycle {
1668
+ private manager;
1669
+ private mounted;
1670
+ /**
1671
+ * Component creation
1672
+ */
1673
+ create(context?: any): Promise<void>;
1674
+ /**
1675
+ * Component mounting
1676
+ */
1677
+ mount(context?: any): Promise<void>;
1678
+ /**
1679
+ * Component updating
1680
+ */
1681
+ update(context?: any): Promise<void>;
1682
+ /**
1683
+ * Component unmounting
1684
+ */
1685
+ unmount(context?: any): Promise<void>;
1686
+ /**
1687
+ * Handle error
1688
+ */
1689
+ error(error: Error, context?: any): Promise<void>;
1690
+ /**
1691
+ * Add lifecycle hook
1692
+ */
1693
+ onPhase(phase: LifecyclePhase, handler: (context?: any) => void, priority?: number): () => void;
1694
+ /**
1695
+ * Subscribe to lifecycle changes
1696
+ */
1697
+ subscribe(listener: (phase: LifecyclePhase) => void): () => void;
1698
+ /**
1699
+ * Get current phase
1700
+ */
1701
+ getPhase(): LifecyclePhase;
1702
+ /**
1703
+ * Check if mounted
1704
+ */
1705
+ isMounted(): boolean;
1706
+ }
1707
+ /**
1708
+ * Create a shared lifecycle instance
1709
+ */
1710
+ declare function createLifecycle(): ComponentLifecycle;
1711
+
1712
+ /**
1713
+ * Property management system for cross-framework components
1714
+ * Handles prop validation, transformation, and binding
1715
+ */
1716
+ type PropType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function' | 'any';
1717
+ interface PropDefinition {
1718
+ type: PropType | PropType[];
1719
+ required?: boolean;
1720
+ default?: any;
1721
+ validator?: (value: any) => boolean;
1722
+ transform?: (value: any) => any;
1723
+ attribute?: string;
1724
+ reflect?: boolean;
1725
+ }
1726
+ interface PropSchema {
1727
+ [key: string]: PropDefinition;
1728
+ }
1729
+ /**
1730
+ * Property manager for components
1731
+ */
1732
+ declare class PropertyManager<T extends Record<string, any> = Record<string, any>> {
1733
+ private schema;
1734
+ private values;
1735
+ private listeners;
1736
+ private transforms;
1737
+ constructor(schema: PropSchema);
1738
+ /**
1739
+ * Initialize default values
1740
+ */
1741
+ private initializeDefaults;
1742
+ /**
1743
+ * Set a property value
1744
+ */
1745
+ set<K extends keyof T>(key: K, value: T[K]): boolean;
1746
+ /**
1747
+ * Get a property value
1748
+ */
1749
+ get<K extends keyof T>(key: K): T[K] | undefined;
1750
+ /**
1751
+ * Get all property values
1752
+ */
1753
+ getAll(): Partial<T>;
1754
+ /**
1755
+ * Validate a property value
1756
+ */
1757
+ validate<K extends keyof T>(key: K, value: any): boolean;
1758
+ /**
1759
+ * Transform a property value
1760
+ */
1761
+ private transform;
1762
+ /**
1763
+ * Subscribe to property changes
1764
+ */
1765
+ subscribe<K extends keyof T>(key: K, listener: (value: T[K]) => void): () => void;
1766
+ /**
1767
+ * Subscribe to all property changes
1768
+ */
1769
+ subscribeAll(listener: (key: keyof T, value: any) => void): () => void;
1770
+ /**
1771
+ * Notify listeners of property change
1772
+ */
1773
+ private notify;
1774
+ /**
1775
+ * Batch update multiple properties
1776
+ */
1777
+ update(props: Partial<T>): void;
1778
+ /**
1779
+ * Reset to default values
1780
+ */
1781
+ reset(): void;
1782
+ /**
1783
+ * Get schema
1784
+ */
1785
+ getSchema(): PropSchema;
1786
+ }
1787
+ /**
1788
+ * Create a property manager
1789
+ */
1790
+ declare function createPropertyManager<T extends Record<string, any>>(schema: PropSchema): PropertyManager<T>;
1791
+ /**
1792
+ * Common prop definitions
1793
+ */
1794
+ declare const CommonProps: {
1795
+ readonly className: {
1796
+ readonly type: PropType;
1797
+ readonly attribute: "class";
1798
+ };
1799
+ readonly style: {
1800
+ readonly type: PropType;
1801
+ };
1802
+ readonly id: {
1803
+ readonly type: PropType;
1804
+ readonly reflect: true;
1805
+ };
1806
+ readonly disabled: {
1807
+ readonly type: PropType;
1808
+ readonly default: false;
1809
+ readonly reflect: true;
1810
+ };
1811
+ readonly hidden: {
1812
+ readonly type: PropType;
1813
+ readonly default: false;
1814
+ readonly reflect: true;
1815
+ };
1816
+ };
1817
+ /**
1818
+ * Product component props
1819
+ */
1820
+ declare const ProductProps: {
1821
+ readonly className: {
1822
+ readonly type: PropType;
1823
+ readonly attribute: "class";
1824
+ };
1825
+ readonly style: {
1826
+ readonly type: PropType;
1827
+ };
1828
+ readonly id: {
1829
+ readonly type: PropType;
1830
+ readonly reflect: true;
1831
+ };
1832
+ readonly disabled: {
1833
+ readonly type: PropType;
1834
+ readonly default: false;
1835
+ readonly reflect: true;
1836
+ };
1837
+ readonly hidden: {
1838
+ readonly type: PropType;
1839
+ readonly default: false;
1840
+ readonly reflect: true;
1841
+ };
1842
+ readonly productId: {
1843
+ readonly type: PropType;
1844
+ readonly attribute: "product-id";
1845
+ readonly reflect: true;
1846
+ };
1847
+ readonly mode: {
1848
+ readonly type: PropType;
1849
+ readonly default: "mock";
1850
+ readonly validator: (value: string) => boolean;
1851
+ };
1852
+ readonly endpoint: {
1853
+ readonly type: PropType;
1854
+ };
1855
+ };
1856
+
1857
+ /**
1858
+ * Component template system for cross-framework components
1859
+ * Provides abstract component definitions that can be rendered by any framework
1860
+ */
1861
+
1862
+ /**
1863
+ * Template node types
1864
+ */
1865
+ type TemplateNodeType = 'element' | 'text' | 'component' | 'fragment' | 'conditional' | 'loop' | 'slot';
1866
+ /**
1867
+ * Template node interface
1868
+ */
1869
+ interface TemplateNode {
1870
+ type: TemplateNodeType;
1871
+ tag?: string;
1872
+ props?: Record<string, any>;
1873
+ children?: TemplateNode[];
1874
+ text?: string;
1875
+ component?: string;
1876
+ condition?: () => boolean;
1877
+ items?: () => any[];
1878
+ renderItem?: (item: any, index: number) => TemplateNode;
1879
+ name?: string;
1880
+ fallback?: TemplateNode[];
1881
+ }
1882
+ /**
1883
+ * Component template definition
1884
+ */
1885
+ interface ComponentTemplate {
1886
+ name: string;
1887
+ props: PropSchema;
1888
+ events?: EventDefinition[];
1889
+ slots?: string[];
1890
+ render: (props: ComponentProps, context?: any) => TemplateNode;
1891
+ }
1892
+ /**
1893
+ * Template builder for creating templates programmatically
1894
+ */
1895
+ declare class TemplateBuilder {
1896
+ /**
1897
+ * Create an element node
1898
+ */
1899
+ static element(tag: string, props?: Record<string, any>, children?: TemplateNode[]): TemplateNode;
1900
+ /**
1901
+ * Create a text node
1902
+ */
1903
+ static text(text: string): TemplateNode;
1904
+ /**
1905
+ * Create a component node
1906
+ */
1907
+ static component(component: string, props?: Record<string, any>, children?: TemplateNode[]): TemplateNode;
1908
+ /**
1909
+ * Create a fragment node
1910
+ */
1911
+ static fragment(children: TemplateNode[]): TemplateNode;
1912
+ /**
1913
+ * Create a conditional node
1914
+ */
1915
+ static if(condition: () => boolean, thenNode: TemplateNode | TemplateNode[], elseNode?: TemplateNode | TemplateNode[]): TemplateNode;
1916
+ /**
1917
+ * Create a loop node
1918
+ */
1919
+ static forEach<T>(items: () => T[], renderItem: (item: T, index: number) => TemplateNode): TemplateNode;
1920
+ /**
1921
+ * Create a slot node
1922
+ */
1923
+ static slot(name: string, fallback?: TemplateNode[]): TemplateNode;
1924
+ }
1925
+ /**
1926
+ * Standard component templates
1927
+ */
1928
+ declare class ComponentTemplates {
1929
+ /**
1930
+ * Product options template
1931
+ */
1932
+ static productOptions(): ComponentTemplate;
1933
+ /**
1934
+ * Product price template
1935
+ */
1936
+ static productPrice(): ComponentTemplate;
1937
+ /**
1938
+ * Product image template
1939
+ */
1940
+ static productImage(): ComponentTemplate;
1941
+ /**
1942
+ * Add to cart button template
1943
+ */
1944
+ static addToCartButton(): ComponentTemplate;
1945
+ }
1946
+ /**
1947
+ * Template renderer interface
1948
+ */
1949
+ interface TemplateRenderer {
1950
+ render(node: TemplateNode, context?: any): any;
1951
+ }
1952
+ /**
1953
+ * Abstract template renderer
1954
+ */
1955
+ declare abstract class AbstractTemplateRenderer implements TemplateRenderer {
1956
+ protected adapter: FrameworkAdapter;
1957
+ constructor(adapter: FrameworkAdapter);
1958
+ /**
1959
+ * Render a template node
1960
+ */
1961
+ render(node: TemplateNode, context?: any): any;
1962
+ /**
1963
+ * Render child nodes
1964
+ */
1965
+ protected renderChildren(children?: TemplateNode[], context?: any): any[];
1966
+ protected abstract renderElement(node: TemplateNode, context?: any): any;
1967
+ protected abstract renderText(node: TemplateNode, context?: any): any;
1968
+ protected abstract renderComponent(node: TemplateNode, context?: any): any;
1969
+ protected abstract renderFragment(node: TemplateNode, context?: any): any;
1970
+ protected abstract renderConditional(node: TemplateNode, context?: any): any;
1971
+ protected abstract renderLoop(node: TemplateNode, context?: any): any;
1972
+ protected abstract renderSlot(node: TemplateNode, context?: any): any;
1973
+ }
1974
+
1975
+ /**
1976
+ * Component registry for managing components across frameworks
1977
+ */
1978
+
1979
+ /**
1980
+ * Component metadata
1981
+ */
1982
+ interface ComponentMetadata {
1983
+ name: string;
1984
+ tagName?: string;
1985
+ displayName?: string;
1986
+ description?: string;
1987
+ props: PropSchema;
1988
+ events?: EventDefinition[];
1989
+ slots?: string[];
1990
+ version?: string;
1991
+ framework?: 'react' | 'vue' | 'svelte' | 'lit' | 'vanilla';
1992
+ }
1993
+ /**
1994
+ * Component definition combining metadata and implementation
1995
+ */
1996
+ interface ComponentDefinition {
1997
+ metadata: ComponentMetadata;
1998
+ descriptor: ComponentDescriptor;
1999
+ implementation?: any;
2000
+ }
2001
+ /**
2002
+ * Global component registry
2003
+ */
2004
+ declare class ComponentRegistry {
2005
+ private components;
2006
+ private frameworks;
2007
+ /**
2008
+ * Register a component
2009
+ */
2010
+ register(definition: ComponentDefinition): void;
2011
+ /**
2012
+ * Get a component definition
2013
+ */
2014
+ get(name: string): ComponentDefinition | undefined;
2015
+ /**
2016
+ * Get all components for a framework
2017
+ */
2018
+ getByFramework(framework: string): ComponentDefinition[];
2019
+ /**
2020
+ * Get all registered components
2021
+ */
2022
+ getAll(): ComponentDefinition[];
2023
+ /**
2024
+ * Check if a component is registered
2025
+ */
2026
+ has(name: string): boolean;
2027
+ /**
2028
+ * Clear registry
2029
+ */
2030
+ clear(): void;
2031
+ }
2032
+ declare const componentRegistry: ComponentRegistry;
2033
+ /**
2034
+ * Standard component definitions for all frameworks
2035
+ */
2036
+ declare const StandardComponents: {
2037
+ /**
2038
+ * Product component
2039
+ */
2040
+ Product: {
2041
+ metadata: {
2042
+ name: string;
2043
+ tagName: string;
2044
+ displayName: string;
2045
+ description: string;
2046
+ props: {
2047
+ productId: {
2048
+ type: "string";
2049
+ };
2050
+ mode: {
2051
+ type: "string";
2052
+ default: string;
2053
+ validator: (v: string) => boolean;
2054
+ };
2055
+ endpoint: {
2056
+ type: "string";
2057
+ };
2058
+ autoLoad: {
2059
+ type: "boolean";
2060
+ default: boolean;
2061
+ };
2062
+ };
2063
+ events: {
2064
+ name: string;
2065
+ bubbles: boolean;
2066
+ }[];
2067
+ slots: string[];
2068
+ };
2069
+ };
2070
+ /**
2071
+ * Product Options component
2072
+ */
2073
+ ProductOptions: {
2074
+ metadata: {
2075
+ name: string;
2076
+ tagName: string;
2077
+ displayName: string;
2078
+ description: string;
2079
+ props: {
2080
+ attributes: {
2081
+ type: "object";
2082
+ };
2083
+ selection: {
2084
+ type: "object";
2085
+ };
2086
+ combinations: {
2087
+ type: "array";
2088
+ };
2089
+ disabled: {
2090
+ type: "boolean";
2091
+ default: boolean;
2092
+ };
2093
+ };
2094
+ events: {
2095
+ name: string;
2096
+ bubbles: boolean;
2097
+ }[];
2098
+ };
2099
+ };
2100
+ /**
2101
+ * Product Price component
2102
+ */
2103
+ ProductPrice: {
2104
+ metadata: {
2105
+ name: string;
2106
+ tagName: string;
2107
+ displayName: string;
2108
+ description: string;
2109
+ props: {
2110
+ price: {
2111
+ type: "number";
2112
+ };
2113
+ currency: {
2114
+ type: "string";
2115
+ default: string;
2116
+ };
2117
+ locale: {
2118
+ type: "string";
2119
+ default: string;
2120
+ };
2121
+ showCurrency: {
2122
+ type: "boolean";
2123
+ default: boolean;
2124
+ };
2125
+ };
2126
+ };
2127
+ };
2128
+ /**
2129
+ * Product Image component
2130
+ */
2131
+ ProductImage: {
2132
+ metadata: {
2133
+ name: string;
2134
+ tagName: string;
2135
+ displayName: string;
2136
+ description: string;
2137
+ props: {
2138
+ productId: {
2139
+ type: "string";
2140
+ };
2141
+ mockupId: {
2142
+ type: "string";
2143
+ };
2144
+ variantId: {
2145
+ type: "string";
2146
+ };
2147
+ width: {
2148
+ type: "number";
2149
+ default: number;
2150
+ };
2151
+ aspectRatio: {
2152
+ type: "string";
2153
+ };
2154
+ design: {
2155
+ type: "object";
2156
+ };
2157
+ };
2158
+ slots: string[];
2159
+ };
2160
+ };
2161
+ /**
2162
+ * Add to Cart component
2163
+ */
2164
+ AddToCart: {
2165
+ metadata: {
2166
+ name: string;
2167
+ tagName: string;
2168
+ displayName: string;
2169
+ description: string;
2170
+ props: {
2171
+ text: {
2172
+ type: "string";
2173
+ default: string;
2174
+ };
2175
+ loadingText: {
2176
+ type: "string";
2177
+ default: string;
2178
+ };
2179
+ successText: {
2180
+ type: "string";
2181
+ default: string;
2182
+ };
2183
+ disabled: {
2184
+ type: "boolean";
2185
+ default: boolean;
2186
+ };
2187
+ quantity: {
2188
+ type: "number";
2189
+ default: number;
2190
+ };
2191
+ };
2192
+ events: {
2193
+ name: string;
2194
+ bubbles: boolean;
2195
+ }[];
2196
+ };
2197
+ };
2198
+ };
2199
+ /**
2200
+ * Register all standard components
2201
+ */
2202
+ declare function registerStandardComponents(): void;
2203
+ /**
2204
+ * Component factory for creating framework-specific implementations
2205
+ */
2206
+ declare class ComponentFactory {
2207
+ /**
2208
+ * Create a React component
2209
+ */
2210
+ static forReact(definition: ComponentDefinition, React: any): any;
2211
+ /**
2212
+ * Create a Vue component
2213
+ */
2214
+ static forVue(definition: ComponentDefinition): any;
2215
+ /**
2216
+ * Create a Svelte component
2217
+ */
2218
+ static forSvelte(definition: ComponentDefinition): any;
2219
+ /**
2220
+ * Create a Web Component
2221
+ */
2222
+ static forWebComponent(definition: ComponentDefinition, LitElement: any): any;
2223
+ }
2224
+ /**
2225
+ * Auto-register components for a framework
2226
+ */
2227
+ declare function autoRegister(framework: string, registrar: (definition: ComponentDefinition) => void): void;
2228
+
2229
+ /**
2230
+ * Lit/Web Components framework adapter implementation
2231
+ */
2232
+
2233
+ /**
2234
+ * Lit adapter implementation for Web Components
2235
+ */
2236
+ declare class LitAdapter implements FrameworkAdapter<ComponentProps> {
2237
+ name: "lit";
2238
+ private element;
2239
+ private properties;
2240
+ private subscriptions;
2241
+ constructor(element?: any);
2242
+ /**
2243
+ * Create a stateful value using reactive properties
2244
+ */
2245
+ createState<T>(initialValue: T): ComponentState<T>;
2246
+ /**
2247
+ * Create a context provider/consumer
2248
+ */
2249
+ createContext<T>(name: string): ComponentContext<T>;
2250
+ /**
2251
+ * Register lifecycle hooks
2252
+ */
2253
+ useLifecycle(lifecycle: ComponentLifecycleHooks): void;
2254
+ /**
2255
+ * Register event handlers
2256
+ */
2257
+ useEvents(handlers: EventHandler[]): void;
2258
+ /**
2259
+ * Create a ref to a DOM element
2260
+ */
2261
+ createRef<T extends HTMLElement>(): {
2262
+ current: T | null;
2263
+ };
2264
+ /**
2265
+ * Render a component
2266
+ */
2267
+ render(component: ComponentDescriptor, props: ComponentProps): any;
2268
+ /**
2269
+ * Get Lit-specific utilities
2270
+ */
2271
+ getUtilities(): FrameworkUtilities;
2272
+ /**
2273
+ * Set the element instance
2274
+ */
2275
+ setElement(element: any): void;
2276
+ }
2277
+ /**
2278
+ * Create a Lit component from a descriptor
2279
+ */
2280
+ declare function createLitComponent(descriptor: ComponentDescriptor, LitElement: any, html: any): any;
2281
+
2282
+ /**
2283
+ * Vue 3 framework adapter implementation
2284
+ */
2285
+
2286
+ /**
2287
+ * Vue 3 adapter implementation
2288
+ */
2289
+ declare class VueAdapter implements FrameworkAdapter<ComponentProps> {
2290
+ name: "vue";
2291
+ private vue;
2292
+ private instance;
2293
+ constructor(vue: any, instance?: any);
2294
+ /**
2295
+ * Create a stateful value using ref/reactive
2296
+ */
2297
+ createState<T>(initialValue: T): ComponentState<T>;
2298
+ /**
2299
+ * Create a context provider/consumer
2300
+ */
2301
+ createContext<T>(name: string): ComponentContext<T>;
2302
+ /**
2303
+ * Register lifecycle hooks
2304
+ */
2305
+ useLifecycle(lifecycle: ComponentLifecycleHooks): void;
2306
+ /**
2307
+ * Register event handlers
2308
+ */
2309
+ useEvents(handlers: EventHandler[]): void;
2310
+ /**
2311
+ * Create a ref to a DOM element
2312
+ */
2313
+ createRef<T extends HTMLElement>(): {
2314
+ current: T | null;
2315
+ };
2316
+ /**
2317
+ * Render a component
2318
+ */
2319
+ render(component: ComponentDescriptor, props: ComponentProps): any;
2320
+ /**
2321
+ * Get Vue-specific utilities
2322
+ */
2323
+ getUtilities(): FrameworkUtilities;
2324
+ }
2325
+ /**
2326
+ * Create a Vue component from a descriptor
2327
+ */
2328
+ declare function createVueComponent(descriptor: ComponentDescriptor, vue: any): any;
2329
+ /**
2330
+ * Composition API hook to use framework adapter
2331
+ */
2332
+ declare function useFrameworkAdapter(vue: any): VueAdapter;
2333
+
2334
+ /**
2335
+ * Svelte framework adapter implementation
2336
+ */
2337
+
2338
+ /**
2339
+ * Svelte adapter implementation
2340
+ */
2341
+ declare class SvelteAdapter implements FrameworkAdapter<ComponentProps> {
2342
+ name: "svelte";
2343
+ private svelte;
2344
+ private component;
2345
+ constructor(svelte: any, component?: any);
2346
+ /**
2347
+ * Create a stateful value using Svelte stores
2348
+ */
2349
+ createState<T>(initialValue: T): ComponentState<T>;
2350
+ /**
2351
+ * Create a context provider/consumer
2352
+ */
2353
+ createContext<T>(name: string): ComponentContext<T>;
2354
+ /**
2355
+ * Register lifecycle hooks
2356
+ */
2357
+ useLifecycle(lifecycle: ComponentLifecycleHooks): void;
2358
+ /**
2359
+ * Register event handlers
2360
+ */
2361
+ useEvents(handlers: EventHandler[]): void;
2362
+ /**
2363
+ * Create a ref to a DOM element
2364
+ */
2365
+ createRef<T extends HTMLElement>(): {
2366
+ current: T | null;
2367
+ };
2368
+ /**
2369
+ * Render a component
2370
+ */
2371
+ render(component: ComponentDescriptor, props: ComponentProps): any;
2372
+ /**
2373
+ * Get Svelte-specific utilities
2374
+ */
2375
+ getUtilities(): FrameworkUtilities;
2376
+ }
2377
+ /**
2378
+ * Create a Svelte component from a descriptor
2379
+ * Note: Svelte components are compiled, so this is more of a template
2380
+ */
2381
+ declare function createSvelteComponent(descriptor: ComponentDescriptor, svelte: any): any;
2382
+
2383
+ interface ProductPlacement {
2384
+ label: string;
2385
+ x: number;
2386
+ y: number;
2387
+ width: number;
2388
+ height: number;
2389
+ rotation?: number;
2390
+ scaleMode?: "fit" | "fill" | "stretch";
2391
+ }
2392
+ interface ProductVariant {
2393
+ id: string;
2394
+ size?: string;
2395
+ color?: string;
2396
+ material?: string;
2397
+ mockupId: string;
2398
+ }
2399
+ interface ProductMockupData {
2400
+ id: string;
2401
+ name: string;
2402
+ placements: ProductPlacement[];
2403
+ variants: ProductVariant[];
2404
+ }
2405
+
2406
+ interface CatalogListResponse {
2407
+ items: CatalogProduct$2[];
2408
+ total: number;
2409
+ }
2410
+
2411
+ interface SdkConfig {
2412
+ baseUrl: string;
2413
+ fetcher?: typeof fetch;
2414
+ mockup?: MockupServiceConfig;
2415
+ mode?: "mock" | "meilisearch";
2416
+ limit?: number;
2417
+ meilisearch?: {
2418
+ host?: string;
2419
+ apiKey?: string;
2420
+ index?: string;
2421
+ };
2422
+ }
2423
+ interface MerchifyClient {
2424
+ catalog: {
2425
+ listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
2426
+ getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct$2>;
2427
+ };
2428
+ mockup: MockupService;
2429
+ }
2430
+ declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
2431
+ declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct$2>;
2432
+ /**
2433
+ * Create a unified Merchify client with catalog and mockup services
2434
+ */
2435
+ declare function createClient(config: SdkConfig): MerchifyClient;
2436
+
2437
+ export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type CartDetail, type CatalogListResponse, type CatalogProduct$2 as CatalogProduct, ClassNames, type ColorDesignElement, ColorPickerUtils, Combination, CommonProps, ComponentContext, type ComponentDefinition, ComponentDescriptor, ComponentEventManager, ComponentFactory, ComponentLifecycle, ComponentLifecycleHooks, type ComponentMetadata, ComponentProps, ComponentRegistry, ComponentState, type ComponentTemplate, ComponentTemplates, type ContainerDescriptor, ContextBridge, type ContextComparator, type ContextConsumer, ContextInjector, type ContextProviderConfig, type ContextSubscriber, ContextSynchronizer, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_COLOR, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type DesignElement, type DesignGenerationContext, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MerchifyClient, type MockupConfig, type MockupGenerationOptions, type MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, type Placement, type PlacementDesign, type ProductArtAlignmentContext, type ProductArtAlignmentDescriptor, type ProductArtAlignmentOptions, type ProductContext, type ProductContextEvents, ProductContextManager, type ProductData, type ProductFetcher, type ProductImageDescriptor, type ProductImageOptions, ProductLoader, type ProductMockupData, type ProductOptionChoice, type ProductOptionData, type ProductOptionsDescriptor, type ProductOptionsOptions, type ProductPlacement, type ProductPriceDescriptor, type ProductPriceOptions, ProductProps, type ProductSpec, type ProductTitleDescriptor, type ProductTitleOptions, type ProductVariant, type PropDefinition, type PropSchema, type PropType, PropertyManager, type RateLimitState, type RegularArtwork, type SdkConfig, type SeamlessPattern, type SignedUrlResponse, StandardComponents, StandardEvents, StateManager, type StateManagerOptions, type StateMiddleware, type StateSelector, type StateSubscriber, type StateUpdater, Styles, SvelteAdapter, SwatchUtils, type TagName, TemplateBuilder, type TemplateNode, type TemplateNodeType, type TemplateRenderer, type TextDescriptor, type TileCount, UniversalContextProvider, type UserSelection, type ValidationError, type ValidationResult, VueAdapter, autoRegister, componentRegistry, config, createAddToCartEvent, createAddToCartHandler, createCartDetail, createClient, createContextProvider, createDesignForPlacements, createErrorHandler, createEventManager, createLifecycle, createLitComponent, createProductContext, createProductLoader, createPropertyManager, createStateHook, createStateStore, createSvelteComponent, createUniversalProvider, createVueComponent, describeArtSelector, describeProductArtAlignment, describeProductImage, describeProductOptions, describeProductPrice, describeProductTitle, extractProductId, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupConfig, resolveMockupId, resolveVariantId, retryOperation, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, withContext, withErrorHandling, withSyncErrorHandling };