@snowcone-app/sdk 0.27.1 → 0.29.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.29.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4590](https://github.com/snowcone-app/snowcone-monorepo/pull/4590) [`d753dfd`](https://github.com/snowcone-app/snowcone-monorepo/commit/d753dfde97f1a296cafb2c9c5d73434ce98fb602) Thanks [@kevinsproles](https://github.com/kevinsproles)! - `@snowcone-app/sdk/mockup-role`: the gallery rules (`PDP_GALLERY_LIMIT`, `galleryStanding`, `ordinaryMockups`, …) as one import-free entry, so a server (the backend's `GET /store/events`) computes "shown to shoppers" from the same rule as the product page without loading the whole sdk.
8
+
9
+ ## 0.28.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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.
14
+
3
15
  ## 0.27.1
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,49 @@
1
+ // src/mockup/mockupRole.ts
2
+ var SIZE_PICTURE = "size-picture";
3
+ function mockupRole(m) {
4
+ const mark = m?.linkedAs;
5
+ if (mark === void 0 || mark === null || mark === "") return "ordinary";
6
+ return mark === SIZE_PICTURE ? SIZE_PICTURE : "other";
7
+ }
8
+ function ordinaryMockups(mockups) {
9
+ return (mockups ?? []).filter((m) => mockupRole(m) === "ordinary");
10
+ }
11
+ var PDP_GALLERY_LIMIT = 10;
12
+ function galleryStanding(mockups, mockupId) {
13
+ const ordinary = ordinaryMockups(mockups);
14
+ const base = { count: ordinary.length, limit: PDP_GALLERY_LIMIT };
15
+ const i = ordinary.findIndex((m2) => m2.id === mockupId);
16
+ if (i >= 0) {
17
+ const shown = i < PDP_GALLERY_LIMIT;
18
+ return { ...base, position: i + 1, shown, reason: shown ? "shown" : "past-limit" };
19
+ }
20
+ const m = (mockups ?? []).find((x) => x.id === mockupId);
21
+ const reason = !m ? "not-published" : mockupRole(m) === SIZE_PICTURE ? "when-size-chosen" : "never-shown";
22
+ return { ...base, position: null, shown: false, reason };
23
+ }
24
+ function pictureForVariant(mockups, variantId) {
25
+ const ordinary = ordinaryMockups(mockups);
26
+ if (variantId) {
27
+ const listed = ordinary.find((m) => (m.gvids ?? []).includes(variantId));
28
+ if (listed) return listed;
29
+ }
30
+ return ordinary[0] ?? null;
31
+ }
32
+ function primaryMockup(mockups) {
33
+ return ordinaryMockups(mockups)[0] ?? null;
34
+ }
35
+ function gallerySizePicture(mockups, selectedVariantId) {
36
+ if (!selectedVariantId) return null;
37
+ return (mockups ?? []).find((m) => mockupRole(m) === SIZE_PICTURE && (m.gvids ?? []).includes(selectedVariantId)) ?? null;
38
+ }
39
+
40
+ export {
41
+ SIZE_PICTURE,
42
+ mockupRole,
43
+ ordinaryMockups,
44
+ PDP_GALLERY_LIMIT,
45
+ galleryStanding,
46
+ pictureForVariant,
47
+ primaryMockup,
48
+ gallerySizePicture
49
+ };
package/dist/index.cjs CHANGED
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
23
  AbstractTemplateRenderer: () => AbstractTemplateRenderer,
24
24
  AdapterRegistry: () => AdapterRegistry,
25
25
  Animations: () => Animations,
@@ -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,
@@ -166,7 +168,7 @@ __export(index_exports, {
166
168
  withErrorHandling: () => withErrorHandling,
167
169
  withSyncErrorHandling: () => withSyncErrorHandling
168
170
  });
169
- module.exports = __toCommonJS(index_exports);
171
+ module.exports = __toCommonJS(src_exports);
170
172
 
171
173
  // src/validation.ts
172
174
  var import_zod = require("zod");
@@ -1088,6 +1090,19 @@ function mockupRole(m) {
1088
1090
  function ordinaryMockups(mockups) {
1089
1091
  return (mockups ?? []).filter((m) => mockupRole(m) === "ordinary");
1090
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
+ }
1091
1106
  function pictureForVariant(mockups, variantId) {
1092
1107
  const ordinary = ordinaryMockups(mockups);
1093
1108
  if (variantId) {
@@ -6654,6 +6669,7 @@ function createClient(config) {
6654
6669
  Focus,
6655
6670
  LifecycleManager,
6656
6671
  LitAdapter,
6672
+ PDP_GALLERY_LIMIT,
6657
6673
  ProductContextManager,
6658
6674
  ProductLoader,
6659
6675
  ProductProps,
@@ -6718,6 +6734,7 @@ function createClient(config) {
6718
6734
  formatPrice,
6719
6735
  formatValidationErrors,
6720
6736
  gallerySizePicture,
6737
+ galleryStanding,
6721
6738
  getBuyUrl,
6722
6739
  getDefaultVariantId,
6723
6740
  getEffectiveAlignment,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { createDevFetcher } from './dev-fetcher.cjs';
2
2
  import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-url';
3
+ export { GalleryReason, GalleryStanding, MockupRole, OrdinaryMockups, PDP_GALLERY_LIMIT, SIZE_PICTURE, gallerySizePicture, galleryStanding, mockupRole, ordinaryMockups, pictureForVariant, primaryMockup } from './mockup-role.cjs';
3
4
  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, P as PlacementSettings, M as MockupResult, R as RealtimeRenderError, h as RealtimeMockupService } from './websocket-CvN0UU2j.cjs';
4
5
  export { A as AdapterRegistry, i as ProductComponentContext, j as RealtimeMockupCallbacks, k as RealtimeMockupState, l as RenderResult, W as WebSocketConfig, m as WebSocketMessage, n as adapterRegistry, o as computeDisabledChoices, p as createComponent, q as defineComponent, r as deriveDefaultSelection, s as findBestCombination, t as getPricePreview, u as isOptionAvailable, v as resolveBestCombination } from './websocket-CvN0UU2j.cjs';
5
6
 
@@ -475,51 +476,6 @@ interface BffSignerOptions {
475
476
  }
476
477
  declare function bffSigner(endpoint?: string, opts?: BffSignerOptions): (url: string) => Promise<string>;
477
478
 
478
- /**
479
- * What a mockup IS on a product page: an ordinary picture, or the picture of ONE size (`json.linkedAs =
480
- * 'size-picture'`: its gvids are that size; a hoodie has eight, S..5XL).
481
- *
482
- * The rule (lead + Kevin, 2026-11-11): the gallery shows exactly ONE size picture, the chosen size's, last; and no
483
- * "the picture for this product / this variant" lookup (cards, links, a variant's preview) ever returns a size
484
- * picture. Every such lookup goes through `pictureForVariant` / `primaryMockup`, which search `ordinaryMockups` only: a
485
- * branded list, so code that forgot the filter does not type-check where an ordinary list is required.
486
- */
487
- declare const SIZE_PICTURE: "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";
495
- type WithRole = {
496
- id?: unknown;
497
- linkedAs?: unknown;
498
- };
499
- type WithGvids = {
500
- id?: string;
501
- gvids?: string[] | null;
502
- };
503
- declare function mockupRole(m: WithRole | null | undefined): MockupRole;
504
- declare const ORDINARY: unique symbol;
505
- /** A product's ordinary pictures (never a size picture). Only `ordinaryMockups` makes one. */
506
- type OrdinaryMockups<T> = readonly T[] & {
507
- readonly [ORDINARY]: true;
508
- };
509
- declare function ordinaryMockups<T extends WithRole>(mockups: readonly T[] | null | undefined): OrdinaryMockups<T>;
510
- /**
511
- * The picture for a variant: the first ordinary mockup that lists it, else the product's first ordinary mockup (its
512
- * fallback picture), else null. Never a size picture, even when a size picture is the only mockup listing the variant.
513
- */
514
- declare function pictureForVariant<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, variantId: string | null | undefined): T | null;
515
- /** The product's picture for cards, links and previews: its first ordinary mockup. Never a size picture. */
516
- declare function primaryMockup<T extends WithRole>(mockups: readonly T[] | null | undefined): T | null;
517
- /**
518
- * The ONE size picture the gallery shows: the size picture whose gvids list the chosen variant, or null (no size
519
- * pictures, or none for this size: never another size's picture).
520
- */
521
- declare function gallerySizePicture<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, selectedVariantId: string | null | undefined): T | null;
522
-
523
479
  /**
524
480
  * Framework-agnostic state management utilities
525
481
  * Provides consistent state management patterns for React and Web Components
@@ -3486,4 +3442,4 @@ declare function searchDesigns(query?: string, options?: SearchDesignsOptions):
3486
3442
  */
3487
3443
  declare function createClient(config: SdkConfig): SnowconeClient;
3488
3444
 
3489
- 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 };
3445
+ 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 MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, 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, 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, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, imageKindOf, isSelectionComplete, isSnowconeSdkError, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupUrl, normalizeChoice, prepareOptionRenderData, 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
@@ -1,5 +1,6 @@
1
1
  export { createDevFetcher } from './dev-fetcher.js';
2
2
  import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-url';
3
+ export { GalleryReason, GalleryStanding, MockupRole, OrdinaryMockups, PDP_GALLERY_LIMIT, SIZE_PICTURE, gallerySizePicture, galleryStanding, mockupRole, ordinaryMockups, pictureForVariant, primaryMockup } from './mockup-role.js';
3
4
  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, P as PlacementSettings, M as MockupResult, R as RealtimeRenderError, h as RealtimeMockupService } from './websocket-CvN0UU2j.js';
4
5
  export { A as AdapterRegistry, i as ProductComponentContext, j as RealtimeMockupCallbacks, k as RealtimeMockupState, l as RenderResult, W as WebSocketConfig, m as WebSocketMessage, n as adapterRegistry, o as computeDisabledChoices, p as createComponent, q as defineComponent, r as deriveDefaultSelection, s as findBestCombination, t as getPricePreview, u as isOptionAvailable, v as resolveBestCombination } from './websocket-CvN0UU2j.js';
5
6
 
@@ -475,51 +476,6 @@ interface BffSignerOptions {
475
476
  }
476
477
  declare function bffSigner(endpoint?: string, opts?: BffSignerOptions): (url: string) => Promise<string>;
477
478
 
478
- /**
479
- * What a mockup IS on a product page: an ordinary picture, or the picture of ONE size (`json.linkedAs =
480
- * 'size-picture'`: its gvids are that size; a hoodie has eight, S..5XL).
481
- *
482
- * The rule (lead + Kevin, 2026-11-11): the gallery shows exactly ONE size picture, the chosen size's, last; and no
483
- * "the picture for this product / this variant" lookup (cards, links, a variant's preview) ever returns a size
484
- * picture. Every such lookup goes through `pictureForVariant` / `primaryMockup`, which search `ordinaryMockups` only: a
485
- * branded list, so code that forgot the filter does not type-check where an ordinary list is required.
486
- */
487
- declare const SIZE_PICTURE: "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";
495
- type WithRole = {
496
- id?: unknown;
497
- linkedAs?: unknown;
498
- };
499
- type WithGvids = {
500
- id?: string;
501
- gvids?: string[] | null;
502
- };
503
- declare function mockupRole(m: WithRole | null | undefined): MockupRole;
504
- declare const ORDINARY: unique symbol;
505
- /** A product's ordinary pictures (never a size picture). Only `ordinaryMockups` makes one. */
506
- type OrdinaryMockups<T> = readonly T[] & {
507
- readonly [ORDINARY]: true;
508
- };
509
- declare function ordinaryMockups<T extends WithRole>(mockups: readonly T[] | null | undefined): OrdinaryMockups<T>;
510
- /**
511
- * The picture for a variant: the first ordinary mockup that lists it, else the product's first ordinary mockup (its
512
- * fallback picture), else null. Never a size picture, even when a size picture is the only mockup listing the variant.
513
- */
514
- declare function pictureForVariant<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, variantId: string | null | undefined): T | null;
515
- /** The product's picture for cards, links and previews: its first ordinary mockup. Never a size picture. */
516
- declare function primaryMockup<T extends WithRole>(mockups: readonly T[] | null | undefined): T | null;
517
- /**
518
- * The ONE size picture the gallery shows: the size picture whose gvids list the chosen variant, or null (no size
519
- * pictures, or none for this size: never another size's picture).
520
- */
521
- declare function gallerySizePicture<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, selectedVariantId: string | null | undefined): T | null;
522
-
523
479
  /**
524
480
  * Framework-agnostic state management utilities
525
481
  * Provides consistent state management patterns for React and Web Components
@@ -3486,4 +3442,4 @@ declare function searchDesigns(query?: string, options?: SearchDesignsOptions):
3486
3442
  */
3487
3443
  declare function createClient(config: SdkConfig): SnowconeClient;
3488
3444
 
3489
- 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 };
3445
+ 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 MockupService, type MockupServiceConfig, OptionAttribute, type OptionChoice, type OptionChoiceRenderData, type OptionRenderData, OptionSelection, 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, 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, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, imageKindOf, isSelectionComplete, isSnowconeSdkError, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupUrl, normalizeChoice, prepareOptionRenderData, 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
@@ -1,10 +1,10 @@
1
- import {
2
- createDevFetcher
3
- } from "./chunk-7VO4EL2V.js";
4
1
  import {
5
2
  REALTIME_WS_URL,
6
3
  RealtimeMockupService
7
4
  } from "./chunk-IW7DXXGY.js";
5
+ import {
6
+ createDevFetcher
7
+ } from "./chunk-7VO4EL2V.js";
8
8
  import {
9
9
  buildMockupUrl,
10
10
  buildPublicMockupUrl,
@@ -12,6 +12,16 @@ import {
12
12
  normalizeDesignElements,
13
13
  normalizeWidth
14
14
  } from "./chunk-ZBJBBIH3.js";
15
+ import {
16
+ PDP_GALLERY_LIMIT,
17
+ SIZE_PICTURE,
18
+ gallerySizePicture,
19
+ galleryStanding,
20
+ mockupRole,
21
+ ordinaryMockups,
22
+ pictureForVariant,
23
+ primaryMockup
24
+ } from "./chunk-FEJ2MJBA.js";
15
25
 
16
26
  // src/validation.ts
17
27
  import { z } from "zod";
@@ -636,32 +646,6 @@ function bffSigner(endpoint = "/api/sign", opts) {
636
646
  };
637
647
  }
638
648
 
639
- // src/mockup/mockupRole.ts
640
- var SIZE_PICTURE = "size-picture";
641
- function mockupRole(m) {
642
- const mark = m?.linkedAs;
643
- if (mark === void 0 || mark === null || mark === "") return "ordinary";
644
- return mark === SIZE_PICTURE ? SIZE_PICTURE : "other";
645
- }
646
- function ordinaryMockups(mockups) {
647
- return (mockups ?? []).filter((m) => mockupRole(m) === "ordinary");
648
- }
649
- function pictureForVariant(mockups, variantId) {
650
- const ordinary = ordinaryMockups(mockups);
651
- if (variantId) {
652
- const listed = ordinary.find((m) => (m.gvids ?? []).includes(variantId));
653
- if (listed) return listed;
654
- }
655
- return ordinary[0] ?? null;
656
- }
657
- function primaryMockup(mockups) {
658
- return ordinaryMockups(mockups)[0] ?? null;
659
- }
660
- function gallerySizePicture(mockups, selectedVariantId) {
661
- if (!selectedVariantId) return null;
662
- return (mockups ?? []).find((m) => mockupRole(m) === SIZE_PICTURE && (m.gvids ?? []).includes(selectedVariantId)) ?? null;
663
- }
664
-
665
649
  // src/state/optionSelection.ts
666
650
  function resolveBestCombination(selection, attributes, combinations) {
667
651
  const relevant = Object.fromEntries(
@@ -5226,6 +5210,7 @@ export {
5226
5210
  Focus,
5227
5211
  LifecycleManager,
5228
5212
  LitAdapter,
5213
+ PDP_GALLERY_LIMIT,
5229
5214
  ProductContextManager,
5230
5215
  ProductLoader,
5231
5216
  ProductProps,
@@ -5290,6 +5275,7 @@ export {
5290
5275
  formatPrice,
5291
5276
  formatValidationErrors,
5292
5277
  gallerySizePicture,
5278
+ galleryStanding,
5293
5279
  getBuyUrl,
5294
5280
  getDefaultVariantId,
5295
5281
  getEffectiveAlignment,
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/mockup/mockupRole.ts
21
+ var mockupRole_exports = {};
22
+ __export(mockupRole_exports, {
23
+ PDP_GALLERY_LIMIT: () => PDP_GALLERY_LIMIT,
24
+ SIZE_PICTURE: () => SIZE_PICTURE,
25
+ gallerySizePicture: () => gallerySizePicture,
26
+ galleryStanding: () => galleryStanding,
27
+ mockupRole: () => mockupRole,
28
+ ordinaryMockups: () => ordinaryMockups,
29
+ pictureForVariant: () => pictureForVariant,
30
+ primaryMockup: () => primaryMockup
31
+ });
32
+ module.exports = __toCommonJS(mockupRole_exports);
33
+ var SIZE_PICTURE = "size-picture";
34
+ function mockupRole(m) {
35
+ const mark = m?.linkedAs;
36
+ if (mark === void 0 || mark === null || mark === "") return "ordinary";
37
+ return mark === SIZE_PICTURE ? SIZE_PICTURE : "other";
38
+ }
39
+ function ordinaryMockups(mockups) {
40
+ return (mockups ?? []).filter((m) => mockupRole(m) === "ordinary");
41
+ }
42
+ var PDP_GALLERY_LIMIT = 10;
43
+ function galleryStanding(mockups, mockupId) {
44
+ const ordinary = ordinaryMockups(mockups);
45
+ const base = { count: ordinary.length, limit: PDP_GALLERY_LIMIT };
46
+ const i = ordinary.findIndex((m2) => m2.id === mockupId);
47
+ if (i >= 0) {
48
+ const shown = i < PDP_GALLERY_LIMIT;
49
+ return { ...base, position: i + 1, shown, reason: shown ? "shown" : "past-limit" };
50
+ }
51
+ const m = (mockups ?? []).find((x) => x.id === mockupId);
52
+ const reason = !m ? "not-published" : mockupRole(m) === SIZE_PICTURE ? "when-size-chosen" : "never-shown";
53
+ return { ...base, position: null, shown: false, reason };
54
+ }
55
+ function pictureForVariant(mockups, variantId) {
56
+ const ordinary = ordinaryMockups(mockups);
57
+ if (variantId) {
58
+ const listed = ordinary.find((m) => (m.gvids ?? []).includes(variantId));
59
+ if (listed) return listed;
60
+ }
61
+ return ordinary[0] ?? null;
62
+ }
63
+ function primaryMockup(mockups) {
64
+ return ordinaryMockups(mockups)[0] ?? null;
65
+ }
66
+ function gallerySizePicture(mockups, selectedVariantId) {
67
+ if (!selectedVariantId) return null;
68
+ return (mockups ?? []).find((m) => mockupRole(m) === SIZE_PICTURE && (m.gvids ?? []).includes(selectedVariantId)) ?? null;
69
+ }
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ PDP_GALLERY_LIMIT,
73
+ SIZE_PICTURE,
74
+ gallerySizePicture,
75
+ galleryStanding,
76
+ mockupRole,
77
+ ordinaryMockups,
78
+ pictureForVariant,
79
+ primaryMockup
80
+ });
@@ -0,0 +1,75 @@
1
+ /**
2
+ * What a mockup IS on a product page: an ordinary picture, or the picture of ONE size (`json.linkedAs =
3
+ * 'size-picture'`: its gvids are that size; a hoodie has eight, S..5XL).
4
+ *
5
+ * The rule (lead + Kevin, 2026-11-11): the gallery shows exactly ONE size picture, the chosen size's, last; and no
6
+ * "the picture for this product / this variant" lookup (cards, links, a variant's preview) ever returns a size
7
+ * picture. Every such lookup goes through `pictureForVariant` / `primaryMockup`, which search `ordinaryMockups` only: a
8
+ * branded list, so code that forgot the filter does not type-check where an ordinary list is required.
9
+ */
10
+ declare const SIZE_PICTURE: "size-picture";
11
+ /**
12
+ * `ordinary` ONLY when the mockup carries no `linkedAs` (an allowlist): any other value is never an ordinary picture.
13
+ * `size-picture` holds the role for its size; `other` is every other mark, e.g. 'size-picture-released' (a pattern
14
+ * picture that handed its size's role to a lay-flat, rendercenter linker #4487) or a role added later: never shown in
15
+ * the gallery, never returned by an ordinary-picture lookup.
16
+ */
17
+ type MockupRole = "ordinary" | typeof SIZE_PICTURE | "other";
18
+ type WithRole = {
19
+ id?: unknown;
20
+ linkedAs?: unknown;
21
+ };
22
+ type WithGvids = {
23
+ id?: string;
24
+ gvids?: string[] | null;
25
+ };
26
+ declare function mockupRole(m: WithRole | null | undefined): MockupRole;
27
+ declare const ORDINARY: unique symbol;
28
+ /** A product's ordinary pictures (never a size picture). Only `ordinaryMockups` makes one. */
29
+ type OrdinaryMockups<T> = readonly T[] & {
30
+ readonly [ORDINARY]: true;
31
+ };
32
+ declare function ordinaryMockups<T extends WithRole>(mockups: readonly T[] | null | undefined): OrdinaryMockups<T>;
33
+ /**
34
+ * How many ordinary pictures the product page's gallery shows: the ONE number www slices with and every staff tool
35
+ * reads to say whether a shopper can see a picture (loom /merch/live: "position 21: not shown, the store shows the
36
+ * first 10"). Never redeclare it locally: a test in www refuses a local gallery limit.
37
+ */
38
+ declare const PDP_GALLERY_LIMIT = 10;
39
+ /**
40
+ * Why a picture is or is not in front of a shopper, in one word a staff page can turn into a sentence:
41
+ * - `shown`: an ordinary picture within the first PDP_GALLERY_LIMIT;
42
+ * - `past-limit`: an ordinary picture after them (published, but no shopper sees it);
43
+ * - `when-size-chosen`: a size picture: not ranked, shown LAST in the gallery when its size is chosen (one per size);
44
+ * - `never-shown`: any other mark (e.g. 'size-picture-released'): never in the gallery;
45
+ * - `not-published`: not in the published list at all (hidden, or gone).
46
+ */
47
+ type GalleryReason = "shown" | "past-limit" | "when-size-chosen" | "never-shown" | "not-published";
48
+ /** Where a picture stands in the shopper's gallery, COMPUTED from the published order (never asserted). */
49
+ interface GalleryStanding {
50
+ /** 1-based position among the ordinary pictures; null for anything that is not an ordinary published picture. */
51
+ position: number | null;
52
+ /** How many ordinary pictures the product has. */
53
+ count: number;
54
+ /** In the ranked gallery a shopper sees by default (reason 'shown'). A size picture is false here: see `reason`. */
55
+ shown: boolean;
56
+ reason: GalleryReason;
57
+ limit: typeof PDP_GALLERY_LIMIT;
58
+ }
59
+ /** `mockups` = the published record's list in gallery order (the catalog's GET /catalog/products/:id, which applies
60
+ * json.mockupOrder): the same list the product page slices. */
61
+ declare function galleryStanding(mockups: readonly WithRole[] | null | undefined, mockupId: string): GalleryStanding;
62
+ /**
63
+ * The picture for a variant: the first ordinary mockup that lists it, else the product's first ordinary mockup (its
64
+ * fallback picture), else null. Never a size picture, even when a size picture is the only mockup listing the variant.
65
+ */
66
+ declare function pictureForVariant<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, variantId: string | null | undefined): T | null;
67
+ /** The product's picture for cards, links and previews: its first ordinary mockup. Never a size picture. */
68
+ declare function primaryMockup<T extends WithRole>(mockups: readonly T[] | null | undefined): T | null;
69
+ /**
70
+ * The ONE size picture the gallery shows: the size picture whose gvids list the chosen variant, or null (no size
71
+ * pictures, or none for this size: never another size's picture).
72
+ */
73
+ declare function gallerySizePicture<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, selectedVariantId: string | null | undefined): T | null;
74
+
75
+ export { type GalleryReason, type GalleryStanding, type MockupRole, type OrdinaryMockups, PDP_GALLERY_LIMIT, SIZE_PICTURE, gallerySizePicture, galleryStanding, mockupRole, ordinaryMockups, pictureForVariant, primaryMockup };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * What a mockup IS on a product page: an ordinary picture, or the picture of ONE size (`json.linkedAs =
3
+ * 'size-picture'`: its gvids are that size; a hoodie has eight, S..5XL).
4
+ *
5
+ * The rule (lead + Kevin, 2026-11-11): the gallery shows exactly ONE size picture, the chosen size's, last; and no
6
+ * "the picture for this product / this variant" lookup (cards, links, a variant's preview) ever returns a size
7
+ * picture. Every such lookup goes through `pictureForVariant` / `primaryMockup`, which search `ordinaryMockups` only: a
8
+ * branded list, so code that forgot the filter does not type-check where an ordinary list is required.
9
+ */
10
+ declare const SIZE_PICTURE: "size-picture";
11
+ /**
12
+ * `ordinary` ONLY when the mockup carries no `linkedAs` (an allowlist): any other value is never an ordinary picture.
13
+ * `size-picture` holds the role for its size; `other` is every other mark, e.g. 'size-picture-released' (a pattern
14
+ * picture that handed its size's role to a lay-flat, rendercenter linker #4487) or a role added later: never shown in
15
+ * the gallery, never returned by an ordinary-picture lookup.
16
+ */
17
+ type MockupRole = "ordinary" | typeof SIZE_PICTURE | "other";
18
+ type WithRole = {
19
+ id?: unknown;
20
+ linkedAs?: unknown;
21
+ };
22
+ type WithGvids = {
23
+ id?: string;
24
+ gvids?: string[] | null;
25
+ };
26
+ declare function mockupRole(m: WithRole | null | undefined): MockupRole;
27
+ declare const ORDINARY: unique symbol;
28
+ /** A product's ordinary pictures (never a size picture). Only `ordinaryMockups` makes one. */
29
+ type OrdinaryMockups<T> = readonly T[] & {
30
+ readonly [ORDINARY]: true;
31
+ };
32
+ declare function ordinaryMockups<T extends WithRole>(mockups: readonly T[] | null | undefined): OrdinaryMockups<T>;
33
+ /**
34
+ * How many ordinary pictures the product page's gallery shows: the ONE number www slices with and every staff tool
35
+ * reads to say whether a shopper can see a picture (loom /merch/live: "position 21: not shown, the store shows the
36
+ * first 10"). Never redeclare it locally: a test in www refuses a local gallery limit.
37
+ */
38
+ declare const PDP_GALLERY_LIMIT = 10;
39
+ /**
40
+ * Why a picture is or is not in front of a shopper, in one word a staff page can turn into a sentence:
41
+ * - `shown`: an ordinary picture within the first PDP_GALLERY_LIMIT;
42
+ * - `past-limit`: an ordinary picture after them (published, but no shopper sees it);
43
+ * - `when-size-chosen`: a size picture: not ranked, shown LAST in the gallery when its size is chosen (one per size);
44
+ * - `never-shown`: any other mark (e.g. 'size-picture-released'): never in the gallery;
45
+ * - `not-published`: not in the published list at all (hidden, or gone).
46
+ */
47
+ type GalleryReason = "shown" | "past-limit" | "when-size-chosen" | "never-shown" | "not-published";
48
+ /** Where a picture stands in the shopper's gallery, COMPUTED from the published order (never asserted). */
49
+ interface GalleryStanding {
50
+ /** 1-based position among the ordinary pictures; null for anything that is not an ordinary published picture. */
51
+ position: number | null;
52
+ /** How many ordinary pictures the product has. */
53
+ count: number;
54
+ /** In the ranked gallery a shopper sees by default (reason 'shown'). A size picture is false here: see `reason`. */
55
+ shown: boolean;
56
+ reason: GalleryReason;
57
+ limit: typeof PDP_GALLERY_LIMIT;
58
+ }
59
+ /** `mockups` = the published record's list in gallery order (the catalog's GET /catalog/products/:id, which applies
60
+ * json.mockupOrder): the same list the product page slices. */
61
+ declare function galleryStanding(mockups: readonly WithRole[] | null | undefined, mockupId: string): GalleryStanding;
62
+ /**
63
+ * The picture for a variant: the first ordinary mockup that lists it, else the product's first ordinary mockup (its
64
+ * fallback picture), else null. Never a size picture, even when a size picture is the only mockup listing the variant.
65
+ */
66
+ declare function pictureForVariant<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, variantId: string | null | undefined): T | null;
67
+ /** The product's picture for cards, links and previews: its first ordinary mockup. Never a size picture. */
68
+ declare function primaryMockup<T extends WithRole>(mockups: readonly T[] | null | undefined): T | null;
69
+ /**
70
+ * The ONE size picture the gallery shows: the size picture whose gvids list the chosen variant, or null (no size
71
+ * pictures, or none for this size: never another size's picture).
72
+ */
73
+ declare function gallerySizePicture<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, selectedVariantId: string | null | undefined): T | null;
74
+
75
+ export { type GalleryReason, type GalleryStanding, type MockupRole, type OrdinaryMockups, PDP_GALLERY_LIMIT, SIZE_PICTURE, gallerySizePicture, galleryStanding, mockupRole, ordinaryMockups, pictureForVariant, primaryMockup };
@@ -0,0 +1,20 @@
1
+ import {
2
+ PDP_GALLERY_LIMIT,
3
+ SIZE_PICTURE,
4
+ gallerySizePicture,
5
+ galleryStanding,
6
+ mockupRole,
7
+ ordinaryMockups,
8
+ pictureForVariant,
9
+ primaryMockup
10
+ } from "./chunk-FEJ2MJBA.js";
11
+ export {
12
+ PDP_GALLERY_LIMIT,
13
+ SIZE_PICTURE,
14
+ gallerySizePicture,
15
+ galleryStanding,
16
+ mockupRole,
17
+ ordinaryMockups,
18
+ pictureForVariant,
19
+ primaryMockup
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowcone-app/sdk",
3
- "version": "0.27.1",
3
+ "version": "0.29.0",
4
4
  "description": "Snowcone SDK for product mockups and print-on-demand",
5
5
  "keywords": [
6
6
  "merch",
@@ -51,6 +51,12 @@
51
51
  "require": "./dist/server.cjs",
52
52
  "default": "./dist/server.js"
53
53
  },
54
+ "./mockup-role": {
55
+ "types": "./dist/mockup-role.d.ts",
56
+ "import": "./dist/mockup-role.js",
57
+ "require": "./dist/mockup-role.cjs",
58
+ "default": "./dist/mockup-role.js"
59
+ },
54
60
  "./package.json": "./package.json"
55
61
  },
56
62
  "files": [
@@ -91,7 +97,7 @@
91
97
  "node": ">=18"
92
98
  },
93
99
  "scripts": {
94
- "build": "tsup src/index.ts src/react.ts src/dev-fetcher.ts src/server.ts --format esm,cjs --dts --external zod --external react",
100
+ "build": "tsup --entry.index src/index.ts --entry.react src/react.ts --entry.dev-fetcher src/dev-fetcher.ts --entry.server src/server.ts --entry.mockup-role src/mockup/mockupRole.ts --format esm,cjs --dts --external zod --external react",
95
101
  "clean": "rm -rf dist",
96
102
  "typecheck": "tsc --project ./tsconfig.json --noEmit",
97
103
  "test": "vitest run"