@snowcone-app/sdk 0.1.12 → 0.1.13
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 +99 -63
- package/dist/{chunk-UJFJ7REN.js → chunk-6MV7TDTM.js} +186 -18
- package/dist/index.cjs +756 -170
- package/dist/index.d.cts +130 -29
- package/dist/index.d.ts +130 -29
- package/dist/index.js +561 -144
- package/dist/react.cjs +203 -20
- package/dist/react.d.cts +13 -1
- package/dist/react.d.ts +13 -1
- package/dist/react.js +18 -3
- package/dist/{websocket-B8_XAwWx.d.ts → websocket-Dum3OooZ.d.cts} +55 -3
- package/dist/{websocket-B8_XAwWx.d.cts → websocket-Dum3OooZ.d.ts} +55 -3
- package/package.json +21 -11
- package/dist/chunk-HOYSZQET.js +0 -476
- package/dist/chunk-IIUCW2O4.js +0 -457
- package/dist/websocket-GXMYofWp.d.cts +0 -330
- package/dist/websocket-GXMYofWp.d.ts +0 -330
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createDevFetcher } from './dev-fetcher.cjs';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-url';
|
|
3
|
+
import { O as OptionAttribute, a as OptionSelection, C as Combination, F as FrameworkAdapter, b as ComponentProps, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities } from './websocket-Dum3OooZ.cjs';
|
|
4
|
+
export { A as AdapterRegistry, M as MockupResult, P as ProductComponentContext, R as RealtimeMockupCallbacks, h as RealtimeMockupService, i as RealtimeMockupState, j as RenderResult, W as WebSocketConfig, k as WebSocketMessage, l as adapterRegistry, m as computeDisabledChoices, n as createComponent, o as defineComponent, p as deriveDefaultSelection, q as findBestCombination, r as getPricePreview, s as isOptionAvailable, t as resolveBestCombination } from './websocket-Dum3OooZ.cjs';
|
|
4
5
|
|
|
5
6
|
interface CatalogProduct$2 {
|
|
6
7
|
id: string;
|
|
@@ -34,8 +35,12 @@ interface CatalogProduct$2 {
|
|
|
34
35
|
};
|
|
35
36
|
};
|
|
36
37
|
combinations?: {
|
|
37
|
-
price
|
|
38
|
-
variantId
|
|
38
|
+
price?: number;
|
|
39
|
+
variantId?: string;
|
|
40
|
+
/**
|
|
41
|
+
* A flat variant row. Carries `price`/`variantId` plus one entry per combination-affecting attribute, keyed by attribute name (e.g. {"Size":"M","Color":"Aqua"}).
|
|
42
|
+
*/
|
|
43
|
+
[k: string]: string | number | undefined;
|
|
39
44
|
}[];
|
|
40
45
|
attributesList?: string[];
|
|
41
46
|
};
|
|
@@ -58,9 +63,13 @@ interface CatalogProduct$2 {
|
|
|
58
63
|
}[];
|
|
59
64
|
placements?: {
|
|
60
65
|
label: string;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
/**
|
|
67
|
+
* URL-safe slug derived from `label` (e.g. "Left sleeve" -> "left_sleeve"). Used to address a placement in the public img/buy wire (asset.<key>, color.<key>).
|
|
68
|
+
*/
|
|
69
|
+
key?: string;
|
|
70
|
+
type?: ('image' | 'color') | null;
|
|
71
|
+
width?: number | null;
|
|
72
|
+
height?: number | null;
|
|
64
73
|
defaultScaleMode?: 'fill' | 'fit';
|
|
65
74
|
fitMarginTop?: number;
|
|
66
75
|
fitMarginRight?: number;
|
|
@@ -72,7 +81,7 @@ interface CatalogProduct$2 {
|
|
|
72
81
|
offsetX?: number;
|
|
73
82
|
offsetY?: number;
|
|
74
83
|
}[];
|
|
75
|
-
defaultGvid?: string;
|
|
84
|
+
defaultGvid?: string | null;
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
/**
|
|
@@ -134,7 +143,7 @@ interface MaskOverride {
|
|
|
134
143
|
id: string;
|
|
135
144
|
blendConfig?: BlendConfig;
|
|
136
145
|
}
|
|
137
|
-
interface GetMockupUrlOptions {
|
|
146
|
+
interface GetMockupUrlOptions$1 {
|
|
138
147
|
design: DesignElement$1[];
|
|
139
148
|
product: ProductSpec;
|
|
140
149
|
effects?: Effects;
|
|
@@ -146,10 +155,11 @@ interface GetMockupUrlOptions {
|
|
|
146
155
|
interface MockupServiceConfig {
|
|
147
156
|
imageUrl?: string;
|
|
148
157
|
signerUrl?: string;
|
|
149
|
-
|
|
158
|
+
/** Public Shop ID (= shop.id). Falls back to SNOWCONE_SHOP_ID env. */
|
|
159
|
+
shop?: string;
|
|
150
160
|
}
|
|
151
161
|
interface MockupService {
|
|
152
|
-
getMockupUrl(options: GetMockupUrlOptions): Promise<string>;
|
|
162
|
+
getMockupUrl(options: GetMockupUrlOptions$1): Promise<string>;
|
|
153
163
|
getConfig(): MockupServiceConfig;
|
|
154
164
|
}
|
|
155
165
|
interface SignedUrlResponse {
|
|
@@ -166,6 +176,88 @@ interface RateLimitState {
|
|
|
166
176
|
};
|
|
167
177
|
}
|
|
168
178
|
|
|
179
|
+
/** Default public host for the image-CDN model (ADR-0076). */
|
|
180
|
+
declare const DEFAULT_MOCKUP_BASE = "https://img.snowcone.app";
|
|
181
|
+
/**
|
|
182
|
+
* What fills one placement, re-exported from `@snowcone-app/mockup-url`:
|
|
183
|
+
* - a bare `string` → an image URL (shorthand for `{ src }`),
|
|
184
|
+
* - `{ src, align?, tile? }` → a positioned/tiled image,
|
|
185
|
+
* - `{ color }` → a solid color (for `type:"color"` placements like a cap's Crown).
|
|
186
|
+
*/
|
|
187
|
+
type Fill = PublicFill;
|
|
188
|
+
/** A design = placement key → {@link Fill}. */
|
|
189
|
+
type Design = PublicDesign;
|
|
190
|
+
/**
|
|
191
|
+
* Options for the code-first {@link getMockupUrl} form.
|
|
192
|
+
*
|
|
193
|
+
* Exactly one artwork source is expected for an image render: either a single
|
|
194
|
+
* default-placement `asset`, OR a multi-placement `design` map. `design` takes
|
|
195
|
+
* precedence if both are given.
|
|
196
|
+
*/
|
|
197
|
+
interface GetMockupUrlOptions {
|
|
198
|
+
/**
|
|
199
|
+
* Your **Shop ID** — the publishable token that identifies + bills the shop.
|
|
200
|
+
* Public and safe to expose (like Cloudinary's cloud name). This is your
|
|
201
|
+
* `shop.id`. Emitted on the URL as `&shop=`.
|
|
202
|
+
*/
|
|
203
|
+
shop: string;
|
|
204
|
+
/**
|
|
205
|
+
* Single default-placement image — the get-started shorthand. Emitted as the
|
|
206
|
+
* readable `asset=` param. Ignored when {@link GetMockupUrlOptions.design} is
|
|
207
|
+
* supplied.
|
|
208
|
+
*/
|
|
209
|
+
asset?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Multi-placement design: a map of placement key → {@link Fill}. Emitted as
|
|
212
|
+
* the dotted `asset.<key>` / `color.<key>` / `tile.<key>` / `align.<key>`
|
|
213
|
+
* params. Takes precedence over `asset`.
|
|
214
|
+
*/
|
|
215
|
+
design?: Design;
|
|
216
|
+
/**
|
|
217
|
+
* Variant option picks: attribute name → choice label (e.g. `{ size: "m" }`).
|
|
218
|
+
* Emitted as `opt.<attr>`. Matched case-insensitively by the resolver.
|
|
219
|
+
*/
|
|
220
|
+
options?: PublicOptions;
|
|
221
|
+
/**
|
|
222
|
+
* Per-shop secret for L3 signed URLs. SERVER-SIDE ONLY — never ship to a
|
|
223
|
+
* browser. When present, an `&signature` HMAC is appended; the resolver
|
|
224
|
+
* verifies it.
|
|
225
|
+
*/
|
|
226
|
+
secret?: string;
|
|
227
|
+
/** Override the public host. Default: `https://img.snowcone.app`. */
|
|
228
|
+
base?: string;
|
|
229
|
+
/** Display width override. */
|
|
230
|
+
width?: number;
|
|
231
|
+
/** Camera view / mockup scene override (`view=<mockupId>`). Emitted as `mockup=`. */
|
|
232
|
+
view?: string;
|
|
233
|
+
/** Specific mockup scene/angle override. Alias of {@link GetMockupUrlOptions.view}. */
|
|
234
|
+
mockup?: string;
|
|
235
|
+
/** Specific variant override (a resolved gvid). */
|
|
236
|
+
variant?: string;
|
|
237
|
+
/** Specific placement label override (only meaningful with a single `asset`). */
|
|
238
|
+
placement?: string;
|
|
239
|
+
/** Mockup canvas aspect ratio. Default 16:9 (omitted from the URL). */
|
|
240
|
+
aspect?: "16:9" | "2:3";
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Build the public mockup image URL. Pure + synchronous — drop the result
|
|
244
|
+
* straight into an `<img src>`.
|
|
245
|
+
*
|
|
246
|
+
* Two call shapes:
|
|
247
|
+
*
|
|
248
|
+
* // Code-first (preferred): productCode then options.
|
|
249
|
+
* getMockupUrl("hoodie-black", { shop, asset });
|
|
250
|
+
* getMockupUrl("KMYKUK", { shop, options: { size: "m" }, design: {…} });
|
|
251
|
+
*
|
|
252
|
+
* // Legacy positional: (assetUrl, productCode, opts).
|
|
253
|
+
* getMockupUrl(assetUrl, "hoodie-black", { shop });
|
|
254
|
+
*
|
|
255
|
+
* The query string is built by `buildPublicMockupUrl` (the shared single source
|
|
256
|
+
* of truth), never hand-rolled here.
|
|
257
|
+
*/
|
|
258
|
+
declare function getMockupUrl(productCode: string, opts: GetMockupUrlOptions): string;
|
|
259
|
+
declare function getMockupUrl(assetUrl: string, productCode: string, opts: GetMockupUrlOptions): string;
|
|
260
|
+
|
|
169
261
|
/**
|
|
170
262
|
* Framework-agnostic state management utilities
|
|
171
263
|
* Provides consistent state management patterns for React and Web Components
|
|
@@ -689,14 +781,6 @@ declare function filterImagePlacements(placements: Placement[]): Placement[];
|
|
|
689
781
|
* Shared mockup URL generation logic for both React and Web Components
|
|
690
782
|
*/
|
|
691
783
|
|
|
692
|
-
interface MockupConfig {
|
|
693
|
-
endpoint?: string;
|
|
694
|
-
mockupUrl?: string;
|
|
695
|
-
signerUrl?: string;
|
|
696
|
-
accountId?: string;
|
|
697
|
-
mode?: "mock" | "live";
|
|
698
|
-
}
|
|
699
|
-
|
|
700
784
|
interface MockupGenerationOptions {
|
|
701
785
|
productId: string;
|
|
702
786
|
mockupId: string;
|
|
@@ -718,14 +802,31 @@ interface MockupGenerationOptions {
|
|
|
718
802
|
* Values are the selected option values
|
|
719
803
|
*/
|
|
720
804
|
type UserSelection = Record<string, string>;
|
|
721
|
-
declare function config(overrides?: MockupConfig): MockupConfig;
|
|
722
805
|
/**
|
|
723
|
-
*
|
|
806
|
+
* Config for the pure URL builder: the two things not on MockupGenerationOptions.
|
|
807
|
+
*/
|
|
808
|
+
interface BuildMockupUrlConfig {
|
|
809
|
+
/** Base of the renderer/CDN, e.g. https://cdn.snowcone.app */
|
|
810
|
+
mockupBaseUrl: string;
|
|
811
|
+
/** The shop's public Shop ID (= shop.id). */
|
|
812
|
+
shop: string;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Pure, deterministic, edge-safe builder for the canonical (UNSIGNED) mockup
|
|
816
|
+
* URL. The actual logic is the SINGLE SOURCE OF TRUTH in
|
|
817
|
+
* `@snowcone-app/mockup-url`, shared byte-for-byte with the edge resolve worker
|
|
818
|
+
* (`workers/mockup-resolver`) so signed URLs are stable CDN cache keys (ADR-0073
|
|
819
|
+
* §10). This thin wrapper preserves the SDK's public signature; it adds no
|
|
820
|
+
* logic of its own (the `maxWidthCache` lives in `mockupUrl`).
|
|
724
821
|
*/
|
|
725
|
-
declare
|
|
822
|
+
declare function buildMockupUrl(options: MockupGenerationOptions, cfg: BuildMockupUrlConfig): string;
|
|
726
823
|
/**
|
|
727
|
-
*
|
|
728
|
-
*
|
|
824
|
+
* Builds the canonical (UNSIGNED) mockup URL from generation options, resolving
|
|
825
|
+
* the base + account from `window.snowcone` / env. Used by the internal live
|
|
826
|
+
* preview path (realtime websocket renders sign internally; the static `<img>`
|
|
827
|
+
* developer flow uses {@link getMockupUrl} instead). No bypass token, no
|
|
828
|
+
* client-side signing — those were deleted with the image-CDN redesign
|
|
829
|
+
* (ADR-0075 §7).
|
|
729
830
|
*/
|
|
730
831
|
declare function mockupUrl(options: MockupGenerationOptions): string;
|
|
731
832
|
/**
|
|
@@ -870,7 +971,7 @@ declare function validateEffects(effects: Effects): ValidationResult;
|
|
|
870
971
|
/**
|
|
871
972
|
* Validates complete mockup URL options
|
|
872
973
|
*/
|
|
873
|
-
declare function validateMockupOptions(options: GetMockupUrlOptions): ValidationResult;
|
|
974
|
+
declare function validateMockupOptions(options: GetMockupUrlOptions$1): ValidationResult;
|
|
874
975
|
/**
|
|
875
976
|
* Helper function to format validation errors as a string
|
|
876
977
|
*/
|
|
@@ -2420,7 +2521,7 @@ interface SdkConfig {
|
|
|
2420
2521
|
index?: string;
|
|
2421
2522
|
};
|
|
2422
2523
|
}
|
|
2423
|
-
interface
|
|
2524
|
+
interface SnowconeClient {
|
|
2424
2525
|
catalog: {
|
|
2425
2526
|
listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
2426
2527
|
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct$2>;
|
|
@@ -2430,8 +2531,8 @@ interface MerchifyClient {
|
|
|
2430
2531
|
declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
2431
2532
|
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct$2>;
|
|
2432
2533
|
/**
|
|
2433
|
-
* Create a unified
|
|
2534
|
+
* Create a unified Snowcone client with catalog and mockup services
|
|
2434
2535
|
*/
|
|
2435
|
-
declare function createClient(config: SdkConfig):
|
|
2536
|
+
declare function createClient(config: SdkConfig): SnowconeClient;
|
|
2436
2537
|
|
|
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
|
|
2538
|
+
export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, 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_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, 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, type SnowconeClient, 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, buildMockupUrl, componentRegistry, 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, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupId, resolveVariantId, retryOperation, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, withContext, withErrorHandling, withSyncErrorHandling };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createDevFetcher } from './dev-fetcher.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-url';
|
|
3
|
+
import { O as OptionAttribute, a as OptionSelection, C as Combination, F as FrameworkAdapter, b as ComponentProps, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities } from './websocket-Dum3OooZ.js';
|
|
4
|
+
export { A as AdapterRegistry, M as MockupResult, P as ProductComponentContext, R as RealtimeMockupCallbacks, h as RealtimeMockupService, i as RealtimeMockupState, j as RenderResult, W as WebSocketConfig, k as WebSocketMessage, l as adapterRegistry, m as computeDisabledChoices, n as createComponent, o as defineComponent, p as deriveDefaultSelection, q as findBestCombination, r as getPricePreview, s as isOptionAvailable, t as resolveBestCombination } from './websocket-Dum3OooZ.js';
|
|
4
5
|
|
|
5
6
|
interface CatalogProduct$2 {
|
|
6
7
|
id: string;
|
|
@@ -34,8 +35,12 @@ interface CatalogProduct$2 {
|
|
|
34
35
|
};
|
|
35
36
|
};
|
|
36
37
|
combinations?: {
|
|
37
|
-
price
|
|
38
|
-
variantId
|
|
38
|
+
price?: number;
|
|
39
|
+
variantId?: string;
|
|
40
|
+
/**
|
|
41
|
+
* A flat variant row. Carries `price`/`variantId` plus one entry per combination-affecting attribute, keyed by attribute name (e.g. {"Size":"M","Color":"Aqua"}).
|
|
42
|
+
*/
|
|
43
|
+
[k: string]: string | number | undefined;
|
|
39
44
|
}[];
|
|
40
45
|
attributesList?: string[];
|
|
41
46
|
};
|
|
@@ -58,9 +63,13 @@ interface CatalogProduct$2 {
|
|
|
58
63
|
}[];
|
|
59
64
|
placements?: {
|
|
60
65
|
label: string;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
/**
|
|
67
|
+
* URL-safe slug derived from `label` (e.g. "Left sleeve" -> "left_sleeve"). Used to address a placement in the public img/buy wire (asset.<key>, color.<key>).
|
|
68
|
+
*/
|
|
69
|
+
key?: string;
|
|
70
|
+
type?: ('image' | 'color') | null;
|
|
71
|
+
width?: number | null;
|
|
72
|
+
height?: number | null;
|
|
64
73
|
defaultScaleMode?: 'fill' | 'fit';
|
|
65
74
|
fitMarginTop?: number;
|
|
66
75
|
fitMarginRight?: number;
|
|
@@ -72,7 +81,7 @@ interface CatalogProduct$2 {
|
|
|
72
81
|
offsetX?: number;
|
|
73
82
|
offsetY?: number;
|
|
74
83
|
}[];
|
|
75
|
-
defaultGvid?: string;
|
|
84
|
+
defaultGvid?: string | null;
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
/**
|
|
@@ -134,7 +143,7 @@ interface MaskOverride {
|
|
|
134
143
|
id: string;
|
|
135
144
|
blendConfig?: BlendConfig;
|
|
136
145
|
}
|
|
137
|
-
interface GetMockupUrlOptions {
|
|
146
|
+
interface GetMockupUrlOptions$1 {
|
|
138
147
|
design: DesignElement$1[];
|
|
139
148
|
product: ProductSpec;
|
|
140
149
|
effects?: Effects;
|
|
@@ -146,10 +155,11 @@ interface GetMockupUrlOptions {
|
|
|
146
155
|
interface MockupServiceConfig {
|
|
147
156
|
imageUrl?: string;
|
|
148
157
|
signerUrl?: string;
|
|
149
|
-
|
|
158
|
+
/** Public Shop ID (= shop.id). Falls back to SNOWCONE_SHOP_ID env. */
|
|
159
|
+
shop?: string;
|
|
150
160
|
}
|
|
151
161
|
interface MockupService {
|
|
152
|
-
getMockupUrl(options: GetMockupUrlOptions): Promise<string>;
|
|
162
|
+
getMockupUrl(options: GetMockupUrlOptions$1): Promise<string>;
|
|
153
163
|
getConfig(): MockupServiceConfig;
|
|
154
164
|
}
|
|
155
165
|
interface SignedUrlResponse {
|
|
@@ -166,6 +176,88 @@ interface RateLimitState {
|
|
|
166
176
|
};
|
|
167
177
|
}
|
|
168
178
|
|
|
179
|
+
/** Default public host for the image-CDN model (ADR-0076). */
|
|
180
|
+
declare const DEFAULT_MOCKUP_BASE = "https://img.snowcone.app";
|
|
181
|
+
/**
|
|
182
|
+
* What fills one placement, re-exported from `@snowcone-app/mockup-url`:
|
|
183
|
+
* - a bare `string` → an image URL (shorthand for `{ src }`),
|
|
184
|
+
* - `{ src, align?, tile? }` → a positioned/tiled image,
|
|
185
|
+
* - `{ color }` → a solid color (for `type:"color"` placements like a cap's Crown).
|
|
186
|
+
*/
|
|
187
|
+
type Fill = PublicFill;
|
|
188
|
+
/** A design = placement key → {@link Fill}. */
|
|
189
|
+
type Design = PublicDesign;
|
|
190
|
+
/**
|
|
191
|
+
* Options for the code-first {@link getMockupUrl} form.
|
|
192
|
+
*
|
|
193
|
+
* Exactly one artwork source is expected for an image render: either a single
|
|
194
|
+
* default-placement `asset`, OR a multi-placement `design` map. `design` takes
|
|
195
|
+
* precedence if both are given.
|
|
196
|
+
*/
|
|
197
|
+
interface GetMockupUrlOptions {
|
|
198
|
+
/**
|
|
199
|
+
* Your **Shop ID** — the publishable token that identifies + bills the shop.
|
|
200
|
+
* Public and safe to expose (like Cloudinary's cloud name). This is your
|
|
201
|
+
* `shop.id`. Emitted on the URL as `&shop=`.
|
|
202
|
+
*/
|
|
203
|
+
shop: string;
|
|
204
|
+
/**
|
|
205
|
+
* Single default-placement image — the get-started shorthand. Emitted as the
|
|
206
|
+
* readable `asset=` param. Ignored when {@link GetMockupUrlOptions.design} is
|
|
207
|
+
* supplied.
|
|
208
|
+
*/
|
|
209
|
+
asset?: string;
|
|
210
|
+
/**
|
|
211
|
+
* Multi-placement design: a map of placement key → {@link Fill}. Emitted as
|
|
212
|
+
* the dotted `asset.<key>` / `color.<key>` / `tile.<key>` / `align.<key>`
|
|
213
|
+
* params. Takes precedence over `asset`.
|
|
214
|
+
*/
|
|
215
|
+
design?: Design;
|
|
216
|
+
/**
|
|
217
|
+
* Variant option picks: attribute name → choice label (e.g. `{ size: "m" }`).
|
|
218
|
+
* Emitted as `opt.<attr>`. Matched case-insensitively by the resolver.
|
|
219
|
+
*/
|
|
220
|
+
options?: PublicOptions;
|
|
221
|
+
/**
|
|
222
|
+
* Per-shop secret for L3 signed URLs. SERVER-SIDE ONLY — never ship to a
|
|
223
|
+
* browser. When present, an `&signature` HMAC is appended; the resolver
|
|
224
|
+
* verifies it.
|
|
225
|
+
*/
|
|
226
|
+
secret?: string;
|
|
227
|
+
/** Override the public host. Default: `https://img.snowcone.app`. */
|
|
228
|
+
base?: string;
|
|
229
|
+
/** Display width override. */
|
|
230
|
+
width?: number;
|
|
231
|
+
/** Camera view / mockup scene override (`view=<mockupId>`). Emitted as `mockup=`. */
|
|
232
|
+
view?: string;
|
|
233
|
+
/** Specific mockup scene/angle override. Alias of {@link GetMockupUrlOptions.view}. */
|
|
234
|
+
mockup?: string;
|
|
235
|
+
/** Specific variant override (a resolved gvid). */
|
|
236
|
+
variant?: string;
|
|
237
|
+
/** Specific placement label override (only meaningful with a single `asset`). */
|
|
238
|
+
placement?: string;
|
|
239
|
+
/** Mockup canvas aspect ratio. Default 16:9 (omitted from the URL). */
|
|
240
|
+
aspect?: "16:9" | "2:3";
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Build the public mockup image URL. Pure + synchronous — drop the result
|
|
244
|
+
* straight into an `<img src>`.
|
|
245
|
+
*
|
|
246
|
+
* Two call shapes:
|
|
247
|
+
*
|
|
248
|
+
* // Code-first (preferred): productCode then options.
|
|
249
|
+
* getMockupUrl("hoodie-black", { shop, asset });
|
|
250
|
+
* getMockupUrl("KMYKUK", { shop, options: { size: "m" }, design: {…} });
|
|
251
|
+
*
|
|
252
|
+
* // Legacy positional: (assetUrl, productCode, opts).
|
|
253
|
+
* getMockupUrl(assetUrl, "hoodie-black", { shop });
|
|
254
|
+
*
|
|
255
|
+
* The query string is built by `buildPublicMockupUrl` (the shared single source
|
|
256
|
+
* of truth), never hand-rolled here.
|
|
257
|
+
*/
|
|
258
|
+
declare function getMockupUrl(productCode: string, opts: GetMockupUrlOptions): string;
|
|
259
|
+
declare function getMockupUrl(assetUrl: string, productCode: string, opts: GetMockupUrlOptions): string;
|
|
260
|
+
|
|
169
261
|
/**
|
|
170
262
|
* Framework-agnostic state management utilities
|
|
171
263
|
* Provides consistent state management patterns for React and Web Components
|
|
@@ -689,14 +781,6 @@ declare function filterImagePlacements(placements: Placement[]): Placement[];
|
|
|
689
781
|
* Shared mockup URL generation logic for both React and Web Components
|
|
690
782
|
*/
|
|
691
783
|
|
|
692
|
-
interface MockupConfig {
|
|
693
|
-
endpoint?: string;
|
|
694
|
-
mockupUrl?: string;
|
|
695
|
-
signerUrl?: string;
|
|
696
|
-
accountId?: string;
|
|
697
|
-
mode?: "mock" | "live";
|
|
698
|
-
}
|
|
699
|
-
|
|
700
784
|
interface MockupGenerationOptions {
|
|
701
785
|
productId: string;
|
|
702
786
|
mockupId: string;
|
|
@@ -718,14 +802,31 @@ interface MockupGenerationOptions {
|
|
|
718
802
|
* Values are the selected option values
|
|
719
803
|
*/
|
|
720
804
|
type UserSelection = Record<string, string>;
|
|
721
|
-
declare function config(overrides?: MockupConfig): MockupConfig;
|
|
722
805
|
/**
|
|
723
|
-
*
|
|
806
|
+
* Config for the pure URL builder: the two things not on MockupGenerationOptions.
|
|
807
|
+
*/
|
|
808
|
+
interface BuildMockupUrlConfig {
|
|
809
|
+
/** Base of the renderer/CDN, e.g. https://cdn.snowcone.app */
|
|
810
|
+
mockupBaseUrl: string;
|
|
811
|
+
/** The shop's public Shop ID (= shop.id). */
|
|
812
|
+
shop: string;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Pure, deterministic, edge-safe builder for the canonical (UNSIGNED) mockup
|
|
816
|
+
* URL. The actual logic is the SINGLE SOURCE OF TRUTH in
|
|
817
|
+
* `@snowcone-app/mockup-url`, shared byte-for-byte with the edge resolve worker
|
|
818
|
+
* (`workers/mockup-resolver`) so signed URLs are stable CDN cache keys (ADR-0073
|
|
819
|
+
* §10). This thin wrapper preserves the SDK's public signature; it adds no
|
|
820
|
+
* logic of its own (the `maxWidthCache` lives in `mockupUrl`).
|
|
724
821
|
*/
|
|
725
|
-
declare
|
|
822
|
+
declare function buildMockupUrl(options: MockupGenerationOptions, cfg: BuildMockupUrlConfig): string;
|
|
726
823
|
/**
|
|
727
|
-
*
|
|
728
|
-
*
|
|
824
|
+
* Builds the canonical (UNSIGNED) mockup URL from generation options, resolving
|
|
825
|
+
* the base + account from `window.snowcone` / env. Used by the internal live
|
|
826
|
+
* preview path (realtime websocket renders sign internally; the static `<img>`
|
|
827
|
+
* developer flow uses {@link getMockupUrl} instead). No bypass token, no
|
|
828
|
+
* client-side signing — those were deleted with the image-CDN redesign
|
|
829
|
+
* (ADR-0075 §7).
|
|
729
830
|
*/
|
|
730
831
|
declare function mockupUrl(options: MockupGenerationOptions): string;
|
|
731
832
|
/**
|
|
@@ -870,7 +971,7 @@ declare function validateEffects(effects: Effects): ValidationResult;
|
|
|
870
971
|
/**
|
|
871
972
|
* Validates complete mockup URL options
|
|
872
973
|
*/
|
|
873
|
-
declare function validateMockupOptions(options: GetMockupUrlOptions): ValidationResult;
|
|
974
|
+
declare function validateMockupOptions(options: GetMockupUrlOptions$1): ValidationResult;
|
|
874
975
|
/**
|
|
875
976
|
* Helper function to format validation errors as a string
|
|
876
977
|
*/
|
|
@@ -2420,7 +2521,7 @@ interface SdkConfig {
|
|
|
2420
2521
|
index?: string;
|
|
2421
2522
|
};
|
|
2422
2523
|
}
|
|
2423
|
-
interface
|
|
2524
|
+
interface SnowconeClient {
|
|
2424
2525
|
catalog: {
|
|
2425
2526
|
listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
2426
2527
|
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct$2>;
|
|
@@ -2430,8 +2531,8 @@ interface MerchifyClient {
|
|
|
2430
2531
|
declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
2431
2532
|
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct$2>;
|
|
2432
2533
|
/**
|
|
2433
|
-
* Create a unified
|
|
2534
|
+
* Create a unified Snowcone client with catalog and mockup services
|
|
2434
2535
|
*/
|
|
2435
|
-
declare function createClient(config: SdkConfig):
|
|
2536
|
+
declare function createClient(config: SdkConfig): SnowconeClient;
|
|
2436
2537
|
|
|
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
|
|
2538
|
+
export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, 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_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, 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, type SnowconeClient, 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, buildMockupUrl, componentRegistry, 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, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupId, resolveVariantId, retryOperation, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, withContext, withErrorHandling, withSyncErrorHandling };
|