@snowcone-app/sdk 0.28.0 → 0.29.1

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.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4643](https://github.com/snowcone-app/snowcone-monorepo/pull/4643) [`af17a28`](https://github.com/snowcone-app/snowcone-monorepo/commit/af17a28ff9a11fa6e59efb83aff3c8dae863a082) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Realtime frame flow control: an `all_mockups_rendered` summary that arrives before its frames (they wait behind the ack window) no longer replaces the frame a picture still has to draw. It was lost, never drawn or acked, and the box waited out its 5 s ack timeout (`E_RT_ACK_TIMEOUT`) on every picture of the gallery. A frame dropped by the per-picture bound (`E_BLOB_PICTURE_BOUND`) is now acked too.
8
+
9
+ ## 0.29.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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.
14
+
3
15
  ## 0.28.0
4
16
 
5
17
  ### Minor Changes
@@ -370,17 +370,23 @@ var RealtimeMockupService = class {
370
370
  }
371
371
  return true;
372
372
  });
373
- const batch = freshMockups.map((mockup) => {
373
+ const batch = freshMockups.flatMap((mockup) => {
374
374
  const existing = this.mockupResults.find(
375
375
  (m) => m.mockupId === mockup.mockupId && (mockup.requestId === void 0 || m.requestId === mockup.requestId)
376
376
  );
377
- if (!existing) return mockup;
377
+ if (!existing) {
378
+ if (!mockup.imageUrl) {
379
+ const held = this.mockupResults.find((m) => m.mockupId === mockup.mockupId && m.imageUrl);
380
+ return held ? [held] : [];
381
+ }
382
+ return [mockup];
383
+ }
378
384
  const merged = { ...existing, ...pruneUndefined(mockup) };
379
385
  if (existing.imageUrl.startsWith("blob:")) {
380
386
  merged.imageUrl = existing.imageUrl;
381
387
  merged.renderUrl = existing.renderUrl;
382
388
  }
383
- return merged;
389
+ return [merged];
384
390
  });
385
391
  const batchById = new Map(batch.map((m) => [m.mockupId, m]));
386
392
  this.mockupResults = [
@@ -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,
@@ -168,7 +168,7 @@ __export(index_exports, {
168
168
  withErrorHandling: () => withErrorHandling,
169
169
  withSyncErrorHandling: () => withSyncErrorHandling
170
170
  });
171
- module.exports = __toCommonJS(index_exports);
171
+ module.exports = __toCommonJS(src_exports);
172
172
 
173
173
  // src/validation.ts
174
174
  var import_zod = require("zod");
@@ -5443,17 +5443,23 @@ var RealtimeMockupService = class {
5443
5443
  }
5444
5444
  return true;
5445
5445
  });
5446
- const batch = freshMockups.map((mockup) => {
5446
+ const batch = freshMockups.flatMap((mockup) => {
5447
5447
  const existing = this.mockupResults.find(
5448
5448
  (m) => m.mockupId === mockup.mockupId && (mockup.requestId === void 0 || m.requestId === mockup.requestId)
5449
5449
  );
5450
- if (!existing) return mockup;
5450
+ if (!existing) {
5451
+ if (!mockup.imageUrl) {
5452
+ const held = this.mockupResults.find((m) => m.mockupId === mockup.mockupId && m.imageUrl);
5453
+ return held ? [held] : [];
5454
+ }
5455
+ return [mockup];
5456
+ }
5451
5457
  const merged = { ...existing, ...pruneUndefined(mockup) };
5452
5458
  if (existing.imageUrl.startsWith("blob:")) {
5453
5459
  merged.imageUrl = existing.imageUrl;
5454
5460
  merged.renderUrl = existing.renderUrl;
5455
5461
  }
5456
- return merged;
5462
+ return [merged];
5457
5463
  });
5458
5464
  const batchById = new Map(batch.map((m) => [m.mockupId, m]));
5459
5465
  this.mockupResults = [
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,80 +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
- * 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;
539
- /**
540
- * The picture for a variant: the first ordinary mockup that lists it, else the product's first ordinary mockup (its
541
- * fallback picture), else null. Never a size picture, even when a size picture is the only mockup listing the variant.
542
- */
543
- declare function pictureForVariant<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, variantId: string | null | undefined): T | null;
544
- /** The product's picture for cards, links and previews: its first ordinary mockup. Never a size picture. */
545
- declare function primaryMockup<T extends WithRole>(mockups: readonly T[] | null | undefined): T | null;
546
- /**
547
- * The ONE size picture the gallery shows: the size picture whose gvids list the chosen variant, or null (no size
548
- * pictures, or none for this size: never another size's picture).
549
- */
550
- declare function gallerySizePicture<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, selectedVariantId: string | null | undefined): T | null;
551
-
552
479
  /**
553
480
  * Framework-agnostic state management utilities
554
481
  * Provides consistent state management patterns for React and Web Components
@@ -3515,4 +3442,4 @@ declare function searchDesigns(query?: string, options?: SearchDesignsOptions):
3515
3442
  */
3516
3443
  declare function createClient(config: SdkConfig): SnowconeClient;
3517
3444
 
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 };
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,80 +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
- * 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;
539
- /**
540
- * The picture for a variant: the first ordinary mockup that lists it, else the product's first ordinary mockup (its
541
- * fallback picture), else null. Never a size picture, even when a size picture is the only mockup listing the variant.
542
- */
543
- declare function pictureForVariant<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, variantId: string | null | undefined): T | null;
544
- /** The product's picture for cards, links and previews: its first ordinary mockup. Never a size picture. */
545
- declare function primaryMockup<T extends WithRole>(mockups: readonly T[] | null | undefined): T | null;
546
- /**
547
- * The ONE size picture the gallery shows: the size picture whose gvids list the chosen variant, or null (no size
548
- * pictures, or none for this size: never another size's picture).
549
- */
550
- declare function gallerySizePicture<T extends WithRole & WithGvids>(mockups: readonly T[] | null | undefined, selectedVariantId: string | null | undefined): T | null;
551
-
552
479
  /**
553
480
  * Framework-agnostic state management utilities
554
481
  * Provides consistent state management patterns for React and Web Components
@@ -3515,4 +3442,4 @@ declare function searchDesigns(query?: string, options?: SearchDesignsOptions):
3515
3442
  */
3516
3443
  declare function createClient(config: SdkConfig): SnowconeClient;
3517
3444
 
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 };
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
- } from "./chunk-IW7DXXGY.js";
4
+ } from "./chunk-4FZOZLWF.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,45 +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
- 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
- }
662
- function pictureForVariant(mockups, variantId) {
663
- const ordinary = ordinaryMockups(mockups);
664
- if (variantId) {
665
- const listed = ordinary.find((m) => (m.gvids ?? []).includes(variantId));
666
- if (listed) return listed;
667
- }
668
- return ordinary[0] ?? null;
669
- }
670
- function primaryMockup(mockups) {
671
- return ordinaryMockups(mockups)[0] ?? null;
672
- }
673
- function gallerySizePicture(mockups, selectedVariantId) {
674
- if (!selectedVariantId) return null;
675
- return (mockups ?? []).find((m) => mockupRole(m) === SIZE_PICTURE && (m.gvids ?? []).includes(selectedVariantId)) ?? null;
676
- }
677
-
678
649
  // src/state/optionSelection.ts
679
650
  function resolveBestCombination(selection, attributes, combinations) {
680
651
  const relevant = Object.fromEntries(
@@ -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/dist/react.cjs CHANGED
@@ -404,17 +404,23 @@ var RealtimeMockupService = class {
404
404
  }
405
405
  return true;
406
406
  });
407
- const batch = freshMockups.map((mockup) => {
407
+ const batch = freshMockups.flatMap((mockup) => {
408
408
  const existing = this.mockupResults.find(
409
409
  (m) => m.mockupId === mockup.mockupId && (mockup.requestId === void 0 || m.requestId === mockup.requestId)
410
410
  );
411
- if (!existing) return mockup;
411
+ if (!existing) {
412
+ if (!mockup.imageUrl) {
413
+ const held = this.mockupResults.find((m) => m.mockupId === mockup.mockupId && m.imageUrl);
414
+ return held ? [held] : [];
415
+ }
416
+ return [mockup];
417
+ }
412
418
  const merged = { ...existing, ...pruneUndefined(mockup) };
413
419
  if (existing.imageUrl.startsWith("blob:")) {
414
420
  merged.imageUrl = existing.imageUrl;
415
421
  merged.renderUrl = existing.renderUrl;
416
422
  }
417
- return merged;
423
+ return [merged];
418
424
  });
419
425
  const batchById = new Map(batch.map((m) => [m.mockupId, m]));
420
426
  this.mockupResults = [
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RealtimeMockupService
3
- } from "./chunk-IW7DXXGY.js";
3
+ } from "./chunk-4FZOZLWF.js";
4
4
 
5
5
  // src/realtime/react.ts
6
6
  import { useCallback, useEffect, useRef, useState } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowcone-app/sdk",
3
- "version": "0.28.0",
3
+ "version": "0.29.1",
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"