@snowcone-app/sdk 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4540](https://github.com/snowcone-app/snowcone-monorepo/pull/4540) [`275d964`](https://github.com/snowcone-app/snowcone-monorepo/commit/275d964b1fbbae1bfbf37094fc9be2edfedcbe3c) Thanks [@kevinsproles](https://github.com/kevinsproles)! - `PDP_GALLERY_LIMIT` (the product page gallery's one limit, 10) and `galleryStanding(mockups, id)`: a picture's position among the ordinary pictures, whether a shopper sees it, and why (`reason`: shown | past-limit | when-size-chosen | never-shown | not-published), computed from the published order.
8
+
9
+ ## 0.27.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#4488](https://github.com/snowcone-app/snowcone-monorepo/pull/4488) [`72cfddc`](https://github.com/snowcone-app/snowcone-monorepo/commit/72cfddc99569dda4ead08c07c11a8af9fc711f2b) Thanks [@kevinsproles](https://github.com/kevinsproles)! - `mockupRole` is an allowlist. A mockup is `ordinary` only when it carries no `linkedAs`, and `'size-picture'` holds its size's role. Any other mark, such as `'size-picture-released'` (a pattern picture that handed its size's role to a lay-flat) or a later role, is `other`: never shown in the gallery and never returned by an ordinary-picture lookup.
14
+
3
15
  ## 0.27.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -49,6 +49,7 @@ __export(index_exports, {
49
49
  Focus: () => Focus,
50
50
  LifecycleManager: () => LifecycleManager,
51
51
  LitAdapter: () => LitAdapter,
52
+ PDP_GALLERY_LIMIT: () => PDP_GALLERY_LIMIT,
52
53
  ProductContextManager: () => ProductContextManager,
53
54
  ProductLoader: () => ProductLoader,
54
55
  ProductProps: () => ProductProps,
@@ -113,6 +114,7 @@ __export(index_exports, {
113
114
  formatPrice: () => formatPrice,
114
115
  formatValidationErrors: () => formatValidationErrors,
115
116
  gallerySizePicture: () => gallerySizePicture,
117
+ galleryStanding: () => galleryStanding,
116
118
  getBuyUrl: () => getBuyUrl,
117
119
  getDefaultVariantId: () => getDefaultVariantId,
118
120
  getEffectiveAlignment: () => getEffectiveAlignment,
@@ -184,7 +186,8 @@ var CatalogProductSchema = import_zod.z.object({
184
186
  ar: import_zod.z.number(),
185
187
  gvids: import_zod.z.array(import_zod.z.string()),
186
188
  // Kept through a successful parse (zod strips undeclared keys): the PDP shows one size picture, the chosen size's.
187
- linkedAs: import_zod.z.literal("size-picture").optional()
189
+ // Any mark is kept (a parse must not strip it): only an absent one is an ordinary picture (mockupRole.ts).
190
+ linkedAs: import_zod.z.string().optional()
188
191
  })
189
192
  ).optional(),
190
193
  options: import_zod.z.object({
@@ -1080,11 +1083,26 @@ function bffSigner(endpoint = "/api/sign", opts) {
1080
1083
  // src/mockup/mockupRole.ts
1081
1084
  var SIZE_PICTURE = "size-picture";
1082
1085
  function mockupRole(m) {
1083
- return m?.linkedAs === SIZE_PICTURE ? SIZE_PICTURE : "ordinary";
1086
+ const mark = m?.linkedAs;
1087
+ if (mark === void 0 || mark === null || mark === "") return "ordinary";
1088
+ return mark === SIZE_PICTURE ? SIZE_PICTURE : "other";
1084
1089
  }
1085
1090
  function ordinaryMockups(mockups) {
1086
1091
  return (mockups ?? []).filter((m) => mockupRole(m) === "ordinary");
1087
1092
  }
1093
+ var PDP_GALLERY_LIMIT = 10;
1094
+ function galleryStanding(mockups, mockupId) {
1095
+ const ordinary = ordinaryMockups(mockups);
1096
+ const base = { count: ordinary.length, limit: PDP_GALLERY_LIMIT };
1097
+ const i = ordinary.findIndex((m2) => m2.id === mockupId);
1098
+ if (i >= 0) {
1099
+ const shown = i < PDP_GALLERY_LIMIT;
1100
+ return { ...base, position: i + 1, shown, reason: shown ? "shown" : "past-limit" };
1101
+ }
1102
+ const m = (mockups ?? []).find((x) => x.id === mockupId);
1103
+ const reason = !m ? "not-published" : mockupRole(m) === SIZE_PICTURE ? "when-size-chosen" : "never-shown";
1104
+ return { ...base, position: null, shown: false, reason };
1105
+ }
1088
1106
  function pictureForVariant(mockups, variantId) {
1089
1107
  const ordinary = ordinaryMockups(mockups);
1090
1108
  if (variantId) {
@@ -6651,6 +6669,7 @@ function createClient(config) {
6651
6669
  Focus,
6652
6670
  LifecycleManager,
6653
6671
  LitAdapter,
6672
+ PDP_GALLERY_LIMIT,
6654
6673
  ProductContextManager,
6655
6674
  ProductLoader,
6656
6675
  ProductProps,
@@ -6715,6 +6734,7 @@ function createClient(config) {
6715
6734
  formatPrice,
6716
6735
  formatValidationErrors,
6717
6736
  gallerySizePicture,
6737
+ galleryStanding,
6718
6738
  getBuyUrl,
6719
6739
  getDefaultVariantId,
6720
6740
  getEffectiveAlignment,
package/dist/index.d.cts CHANGED
@@ -24,9 +24,9 @@ interface CatalogProduct {
24
24
  [k: string]: string;
25
25
  };
26
26
  /**
27
- * What this mockup is on the product page. 'size-picture': the picture of ONE size (its gvids are that size). The gallery shows only the chosen size's one, last; ordinary-picture lookups (a variant's picture, a card) never return it. Absent on ordinary mockups.
27
+ * What this mockup is on the product page. 'size-picture': the picture of ONE size (its gvids are that size). The gallery shows only the chosen size's one, last; ordinary-picture lookups (a variant's picture, a card) never return it. 'size-picture-released': a picture that handed its size's role to another (never shown, never an ordinary picture). Absent on ordinary mockups.
28
28
  */
29
- linkedAs?: "size-picture";
29
+ linkedAs?: "size-picture" | "size-picture-released";
30
30
  }[];
31
31
  options?: {
32
32
  selected?: {
@@ -485,7 +485,13 @@ declare function bffSigner(endpoint?: string, opts?: BffSignerOptions): (url: st
485
485
  * branded list, so code that forgot the filter does not type-check where an ordinary list is required.
486
486
  */
487
487
  declare const SIZE_PICTURE: "size-picture";
488
- type MockupRole = "ordinary" | typeof SIZE_PICTURE;
488
+ /**
489
+ * `ordinary` ONLY when the mockup carries no `linkedAs` (an allowlist): any other value is never an ordinary picture.
490
+ * `size-picture` holds the role for its size; `other` is every other mark, e.g. 'size-picture-released' (a pattern
491
+ * picture that handed its size's role to a lay-flat, rendercenter linker #4487) or a role added later: never shown in
492
+ * the gallery, never returned by an ordinary-picture lookup.
493
+ */
494
+ type MockupRole = "ordinary" | typeof SIZE_PICTURE | "other";
489
495
  type WithRole = {
490
496
  id?: unknown;
491
497
  linkedAs?: unknown;
@@ -501,6 +507,35 @@ type OrdinaryMockups<T> = readonly T[] & {
501
507
  readonly [ORDINARY]: true;
502
508
  };
503
509
  declare function ordinaryMockups<T extends WithRole>(mockups: readonly T[] | null | undefined): OrdinaryMockups<T>;
510
+ /**
511
+ * How many ordinary pictures the product page's gallery shows: the ONE number www slices with and every staff tool
512
+ * reads to say whether a shopper can see a picture (loom /merch/live: "position 21: not shown, the store shows the
513
+ * first 10"). Never redeclare it locally: a test in www refuses a local gallery limit.
514
+ */
515
+ declare const PDP_GALLERY_LIMIT = 10;
516
+ /**
517
+ * Why a picture is or is not in front of a shopper, in one word a staff page can turn into a sentence:
518
+ * - `shown`: an ordinary picture within the first PDP_GALLERY_LIMIT;
519
+ * - `past-limit`: an ordinary picture after them (published, but no shopper sees it);
520
+ * - `when-size-chosen`: a size picture: not ranked, shown LAST in the gallery when its size is chosen (one per size);
521
+ * - `never-shown`: any other mark (e.g. 'size-picture-released'): never in the gallery;
522
+ * - `not-published`: not in the published list at all (hidden, or gone).
523
+ */
524
+ type GalleryReason = "shown" | "past-limit" | "when-size-chosen" | "never-shown" | "not-published";
525
+ /** Where a picture stands in the shopper's gallery, COMPUTED from the published order (never asserted). */
526
+ interface GalleryStanding {
527
+ /** 1-based position among the ordinary pictures; null for anything that is not an ordinary published picture. */
528
+ position: number | null;
529
+ /** How many ordinary pictures the product has. */
530
+ count: number;
531
+ /** In the ranked gallery a shopper sees by default (reason 'shown'). A size picture is false here: see `reason`. */
532
+ shown: boolean;
533
+ reason: GalleryReason;
534
+ limit: typeof PDP_GALLERY_LIMIT;
535
+ }
536
+ /** `mockups` = the published record's list in gallery order (the catalog's GET /catalog/products/:id, which applies
537
+ * json.mockupOrder): the same list the product page slices. */
538
+ declare function galleryStanding(mockups: readonly WithRole[] | null | undefined, mockupId: string): GalleryStanding;
504
539
  /**
505
540
  * The picture for a variant: the first ordinary mockup that lists it, else the product's first ordinary mockup (its
506
541
  * fallback picture), else null. Never a size picture, even when a size picture is the only mockup listing the variant.
@@ -3480,4 +3515,4 @@ declare function searchDesigns(query?: string, options?: SearchDesignsOptions):
3480
3515
  */
3481
3516
  declare function createClient(config: SdkConfig): SnowconeClient;
3482
3517
 
3483
- 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 CatalogDesign, type CatalogListResponse, type 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, type CreateDesignStateInput, type CreatedDesignState, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_BUY_BASE, DEFAULT_COLOR, DEFAULT_GRANT_BASE, DEFAULT_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type DesignsSearchResponse, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type FailedAsset, type FetchMockupImageOptions, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, type MockupImage, MockupResult, type MockupRole, type MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, type OrdinaryMockups, type Placement, type PlacementDesign, PlacementSettings, 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, REALTIME_WS_URL, type RateLimitState, type RealtimeGrant, RealtimeMockupService, RealtimeRenderError, type RegularArtwork, type RenderProduct, type RenderProductAttribute, type RenderProductAttributeChoice, type RenderProductCombination, type RenderProductMockup, type RenderProductOptions, type RenderProductRequiredPlacement, RenderSession, type RenderSessionOptions, type RenderState, SIZE_PICTURE, type SdkConfig, type SeamlessPattern, type SearchDesignsOptions, type SignedUrlResponse, type SnowconeClient, SnowconeSdkError, type SnowconeSdkErrorCode, 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, assertVariantSelected, autoRegister, bffSigner, buildMockupUrl, componentRegistry, createAddToCartEvent, createAddToCartHandler, createCartDetail, createClient, createContextProvider, createDesignForPlacements, createDesignState, createErrorHandler, createEventManager, createLifecycle, createLitComponent, createProductContext, createProductLoader, createPropertyManager, createStateHook, createStateStore, createSvelteComponent, createUniversalProvider, createVueComponent, describeArtSelector, describeProductArtAlignment, describeProductImage, describeProductOptions, describeProductPrice, describeProductTitle, extractProductId, fetchMockupImage, fetchRealtimeGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, gallerySizePicture, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, imageKindOf, isSelectionComplete, isSnowconeSdkError, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupRole, mockupUrl, normalizeChoice, ordinaryMockups, pictureForVariant, prepareOptionRenderData, primaryMockup, registerStandardComponents, resolveMockupId, resolvePreviewVariantId, resolveVariantId, retryOperation, searchDesigns, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
3518
+ 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 CatalogDesign, type CatalogListResponse, type 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, type CreateDesignStateInput, type CreatedDesignState, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_BUY_BASE, DEFAULT_COLOR, DEFAULT_GRANT_BASE, DEFAULT_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type DesignsSearchResponse, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type FailedAsset, type FetchMockupImageOptions, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GalleryReason, type GalleryStanding, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, type MockupImage, MockupResult, type MockupRole, type MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, type OrdinaryMockups, PDP_GALLERY_LIMIT, type Placement, type PlacementDesign, PlacementSettings, 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, REALTIME_WS_URL, type RateLimitState, type RealtimeGrant, RealtimeMockupService, RealtimeRenderError, type RegularArtwork, type RenderProduct, type RenderProductAttribute, type RenderProductAttributeChoice, type RenderProductCombination, type RenderProductMockup, type RenderProductOptions, type RenderProductRequiredPlacement, RenderSession, type RenderSessionOptions, type RenderState, SIZE_PICTURE, type SdkConfig, type SeamlessPattern, type SearchDesignsOptions, type SignedUrlResponse, type SnowconeClient, SnowconeSdkError, type SnowconeSdkErrorCode, 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, assertVariantSelected, autoRegister, bffSigner, buildMockupUrl, componentRegistry, createAddToCartEvent, createAddToCartHandler, createCartDetail, createClient, createContextProvider, createDesignForPlacements, createDesignState, createErrorHandler, createEventManager, createLifecycle, createLitComponent, createProductContext, createProductLoader, createPropertyManager, createStateHook, createStateStore, createSvelteComponent, createUniversalProvider, createVueComponent, describeArtSelector, describeProductArtAlignment, describeProductImage, describeProductOptions, describeProductPrice, describeProductTitle, extractProductId, fetchMockupImage, fetchRealtimeGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, gallerySizePicture, galleryStanding, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, imageKindOf, isSelectionComplete, isSnowconeSdkError, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupRole, mockupUrl, normalizeChoice, ordinaryMockups, pictureForVariant, prepareOptionRenderData, primaryMockup, registerStandardComponents, resolveMockupId, resolvePreviewVariantId, resolveVariantId, retryOperation, searchDesigns, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
package/dist/index.d.ts CHANGED
@@ -24,9 +24,9 @@ interface CatalogProduct {
24
24
  [k: string]: string;
25
25
  };
26
26
  /**
27
- * What this mockup is on the product page. 'size-picture': the picture of ONE size (its gvids are that size). The gallery shows only the chosen size's one, last; ordinary-picture lookups (a variant's picture, a card) never return it. Absent on ordinary mockups.
27
+ * What this mockup is on the product page. 'size-picture': the picture of ONE size (its gvids are that size). The gallery shows only the chosen size's one, last; ordinary-picture lookups (a variant's picture, a card) never return it. 'size-picture-released': a picture that handed its size's role to another (never shown, never an ordinary picture). Absent on ordinary mockups.
28
28
  */
29
- linkedAs?: "size-picture";
29
+ linkedAs?: "size-picture" | "size-picture-released";
30
30
  }[];
31
31
  options?: {
32
32
  selected?: {
@@ -485,7 +485,13 @@ declare function bffSigner(endpoint?: string, opts?: BffSignerOptions): (url: st
485
485
  * branded list, so code that forgot the filter does not type-check where an ordinary list is required.
486
486
  */
487
487
  declare const SIZE_PICTURE: "size-picture";
488
- type MockupRole = "ordinary" | typeof SIZE_PICTURE;
488
+ /**
489
+ * `ordinary` ONLY when the mockup carries no `linkedAs` (an allowlist): any other value is never an ordinary picture.
490
+ * `size-picture` holds the role for its size; `other` is every other mark, e.g. 'size-picture-released' (a pattern
491
+ * picture that handed its size's role to a lay-flat, rendercenter linker #4487) or a role added later: never shown in
492
+ * the gallery, never returned by an ordinary-picture lookup.
493
+ */
494
+ type MockupRole = "ordinary" | typeof SIZE_PICTURE | "other";
489
495
  type WithRole = {
490
496
  id?: unknown;
491
497
  linkedAs?: unknown;
@@ -501,6 +507,35 @@ type OrdinaryMockups<T> = readonly T[] & {
501
507
  readonly [ORDINARY]: true;
502
508
  };
503
509
  declare function ordinaryMockups<T extends WithRole>(mockups: readonly T[] | null | undefined): OrdinaryMockups<T>;
510
+ /**
511
+ * How many ordinary pictures the product page's gallery shows: the ONE number www slices with and every staff tool
512
+ * reads to say whether a shopper can see a picture (loom /merch/live: "position 21: not shown, the store shows the
513
+ * first 10"). Never redeclare it locally: a test in www refuses a local gallery limit.
514
+ */
515
+ declare const PDP_GALLERY_LIMIT = 10;
516
+ /**
517
+ * Why a picture is or is not in front of a shopper, in one word a staff page can turn into a sentence:
518
+ * - `shown`: an ordinary picture within the first PDP_GALLERY_LIMIT;
519
+ * - `past-limit`: an ordinary picture after them (published, but no shopper sees it);
520
+ * - `when-size-chosen`: a size picture: not ranked, shown LAST in the gallery when its size is chosen (one per size);
521
+ * - `never-shown`: any other mark (e.g. 'size-picture-released'): never in the gallery;
522
+ * - `not-published`: not in the published list at all (hidden, or gone).
523
+ */
524
+ type GalleryReason = "shown" | "past-limit" | "when-size-chosen" | "never-shown" | "not-published";
525
+ /** Where a picture stands in the shopper's gallery, COMPUTED from the published order (never asserted). */
526
+ interface GalleryStanding {
527
+ /** 1-based position among the ordinary pictures; null for anything that is not an ordinary published picture. */
528
+ position: number | null;
529
+ /** How many ordinary pictures the product has. */
530
+ count: number;
531
+ /** In the ranked gallery a shopper sees by default (reason 'shown'). A size picture is false here: see `reason`. */
532
+ shown: boolean;
533
+ reason: GalleryReason;
534
+ limit: typeof PDP_GALLERY_LIMIT;
535
+ }
536
+ /** `mockups` = the published record's list in gallery order (the catalog's GET /catalog/products/:id, which applies
537
+ * json.mockupOrder): the same list the product page slices. */
538
+ declare function galleryStanding(mockups: readonly WithRole[] | null | undefined, mockupId: string): GalleryStanding;
504
539
  /**
505
540
  * The picture for a variant: the first ordinary mockup that lists it, else the product's first ordinary mockup (its
506
541
  * fallback picture), else null. Never a size picture, even when a size picture is the only mockup listing the variant.
@@ -3480,4 +3515,4 @@ declare function searchDesigns(query?: string, options?: SearchDesignsOptions):
3480
3515
  */
3481
3516
  declare function createClient(config: SdkConfig): SnowconeClient;
3482
3517
 
3483
- 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 CatalogDesign, type CatalogListResponse, type 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, type CreateDesignStateInput, type CreatedDesignState, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_BUY_BASE, DEFAULT_COLOR, DEFAULT_GRANT_BASE, DEFAULT_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type DesignsSearchResponse, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type FailedAsset, type FetchMockupImageOptions, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, type MockupImage, MockupResult, type MockupRole, type MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, type OrdinaryMockups, type Placement, type PlacementDesign, PlacementSettings, 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, REALTIME_WS_URL, type RateLimitState, type RealtimeGrant, RealtimeMockupService, RealtimeRenderError, type RegularArtwork, type RenderProduct, type RenderProductAttribute, type RenderProductAttributeChoice, type RenderProductCombination, type RenderProductMockup, type RenderProductOptions, type RenderProductRequiredPlacement, RenderSession, type RenderSessionOptions, type RenderState, SIZE_PICTURE, type SdkConfig, type SeamlessPattern, type SearchDesignsOptions, type SignedUrlResponse, type SnowconeClient, SnowconeSdkError, type SnowconeSdkErrorCode, 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, assertVariantSelected, autoRegister, bffSigner, buildMockupUrl, componentRegistry, createAddToCartEvent, createAddToCartHandler, createCartDetail, createClient, createContextProvider, createDesignForPlacements, createDesignState, createErrorHandler, createEventManager, createLifecycle, createLitComponent, createProductContext, createProductLoader, createPropertyManager, createStateHook, createStateStore, createSvelteComponent, createUniversalProvider, createVueComponent, describeArtSelector, describeProductArtAlignment, describeProductImage, describeProductOptions, describeProductPrice, describeProductTitle, extractProductId, fetchMockupImage, fetchRealtimeGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, gallerySizePicture, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, imageKindOf, isSelectionComplete, isSnowconeSdkError, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupRole, mockupUrl, normalizeChoice, ordinaryMockups, pictureForVariant, prepareOptionRenderData, primaryMockup, registerStandardComponents, resolveMockupId, resolvePreviewVariantId, resolveVariantId, retryOperation, searchDesigns, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
3518
+ 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 CatalogDesign, type CatalogListResponse, type 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, type CreateDesignStateInput, type CreatedDesignState, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_BUY_BASE, DEFAULT_COLOR, DEFAULT_GRANT_BASE, DEFAULT_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type DesignsSearchResponse, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type FailedAsset, type FetchMockupImageOptions, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GalleryReason, type GalleryStanding, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, type MockupImage, MockupResult, type MockupRole, type MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, type OrdinaryMockups, PDP_GALLERY_LIMIT, type Placement, type PlacementDesign, PlacementSettings, 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, REALTIME_WS_URL, type RateLimitState, type RealtimeGrant, RealtimeMockupService, RealtimeRenderError, type RegularArtwork, type RenderProduct, type RenderProductAttribute, type RenderProductAttributeChoice, type RenderProductCombination, type RenderProductMockup, type RenderProductOptions, type RenderProductRequiredPlacement, RenderSession, type RenderSessionOptions, type RenderState, SIZE_PICTURE, type SdkConfig, type SeamlessPattern, type SearchDesignsOptions, type SignedUrlResponse, type SnowconeClient, SnowconeSdkError, type SnowconeSdkErrorCode, 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, assertVariantSelected, autoRegister, bffSigner, buildMockupUrl, componentRegistry, createAddToCartEvent, createAddToCartHandler, createCartDetail, createClient, createContextProvider, createDesignForPlacements, createDesignState, createErrorHandler, createEventManager, createLifecycle, createLitComponent, createProductContext, createProductLoader, createPropertyManager, createStateHook, createStateStore, createSvelteComponent, createUniversalProvider, createVueComponent, describeArtSelector, describeProductArtAlignment, describeProductImage, describeProductOptions, describeProductPrice, describeProductTitle, extractProductId, fetchMockupImage, fetchRealtimeGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, gallerySizePicture, galleryStanding, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, imageKindOf, isSelectionComplete, isSnowconeSdkError, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupRole, mockupUrl, normalizeChoice, ordinaryMockups, pictureForVariant, prepareOptionRenderData, primaryMockup, registerStandardComponents, resolveMockupId, resolvePreviewVariantId, resolveVariantId, retryOperation, searchDesigns, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
package/dist/index.js CHANGED
@@ -29,7 +29,8 @@ var CatalogProductSchema = z.object({
29
29
  ar: z.number(),
30
30
  gvids: z.array(z.string()),
31
31
  // Kept through a successful parse (zod strips undeclared keys): the PDP shows one size picture, the chosen size's.
32
- linkedAs: z.literal("size-picture").optional()
32
+ // Any mark is kept (a parse must not strip it): only an absent one is an ordinary picture (mockupRole.ts).
33
+ linkedAs: z.string().optional()
33
34
  })
34
35
  ).optional(),
35
36
  options: z.object({
@@ -638,11 +639,26 @@ function bffSigner(endpoint = "/api/sign", opts) {
638
639
  // src/mockup/mockupRole.ts
639
640
  var SIZE_PICTURE = "size-picture";
640
641
  function mockupRole(m) {
641
- return m?.linkedAs === SIZE_PICTURE ? SIZE_PICTURE : "ordinary";
642
+ const mark = m?.linkedAs;
643
+ if (mark === void 0 || mark === null || mark === "") return "ordinary";
644
+ return mark === SIZE_PICTURE ? SIZE_PICTURE : "other";
642
645
  }
643
646
  function ordinaryMockups(mockups) {
644
647
  return (mockups ?? []).filter((m) => mockupRole(m) === "ordinary");
645
648
  }
649
+ var PDP_GALLERY_LIMIT = 10;
650
+ function galleryStanding(mockups, mockupId) {
651
+ const ordinary = ordinaryMockups(mockups);
652
+ const base = { count: ordinary.length, limit: PDP_GALLERY_LIMIT };
653
+ const i = ordinary.findIndex((m2) => m2.id === mockupId);
654
+ if (i >= 0) {
655
+ const shown = i < PDP_GALLERY_LIMIT;
656
+ return { ...base, position: i + 1, shown, reason: shown ? "shown" : "past-limit" };
657
+ }
658
+ const m = (mockups ?? []).find((x) => x.id === mockupId);
659
+ const reason = !m ? "not-published" : mockupRole(m) === SIZE_PICTURE ? "when-size-chosen" : "never-shown";
660
+ return { ...base, position: null, shown: false, reason };
661
+ }
646
662
  function pictureForVariant(mockups, variantId) {
647
663
  const ordinary = ordinaryMockups(mockups);
648
664
  if (variantId) {
@@ -5223,6 +5239,7 @@ export {
5223
5239
  Focus,
5224
5240
  LifecycleManager,
5225
5241
  LitAdapter,
5242
+ PDP_GALLERY_LIMIT,
5226
5243
  ProductContextManager,
5227
5244
  ProductLoader,
5228
5245
  ProductProps,
@@ -5287,6 +5304,7 @@ export {
5287
5304
  formatPrice,
5288
5305
  formatValidationErrors,
5289
5306
  gallerySizePicture,
5307
+ galleryStanding,
5290
5308
  getBuyUrl,
5291
5309
  getDefaultVariantId,
5292
5310
  getEffectiveAlignment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowcone-app/sdk",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Snowcone SDK for product mockups and print-on-demand",
5
5
  "keywords": [
6
6
  "merch",