@snowcone-app/sdk 0.29.1 → 0.31.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/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { createDevFetcher } from './dev-fetcher.cjs';
2
- import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-url';
2
+ import { PublicDesign, PublicFill, PublicOptions, MockupAspect, MockupPreset } from '@snowcone-app/mockup-url';
3
+ export { SNOWCONE_HOSTS, SNOWCONE_REALTIME_WS_URL, SnowconeHostRole } from '@snowcone-app/mockup-url';
3
4
  export { GalleryReason, GalleryStanding, MockupRole, OrdinaryMockups, PDP_GALLERY_LIMIT, SIZE_PICTURE, gallerySizePicture, galleryStanding, mockupRole, ordinaryMockups, pictureForVariant, primaryMockup } from './mockup-role.cjs';
4
5
  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';
5
6
  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';
@@ -238,8 +239,9 @@ interface ProductSpec {
238
239
  interface Effects {
239
240
  grain?: 1 | 2;
240
241
  }
241
- /** Supported aspect ratios */
242
- type AspectRatio = '16:9' | '2:3';
242
+ /** Picture shapes (`aspect=`): the same list as @snowcone-app/mockup-url MOCKUP_ASPECTS. A mockup gives 16:9 + 2:3,
243
+ * or the shapes its plate holds; asking another answers E_MOCKUP_SHAPE_UNAVAILABLE with its list. */
244
+ type AspectRatio = '16:9' | '2:3' | '3:4' | '4:5' | '1:1' | '1.91:1' | '9:16' | '21:9' | 'app-header';
243
245
  /**
244
246
  * Blend configuration for mockup masks
245
247
  * Controls how artwork blends with the background texture
@@ -297,7 +299,7 @@ interface RateLimitState {
297
299
  }
298
300
 
299
301
  /** Default public host for the image-CDN model (ADR-0076). */
300
- declare const DEFAULT_MOCKUP_BASE = "https://img.snowcone.app";
302
+ declare const DEFAULT_MOCKUP_BASE: string;
301
303
  /**
302
304
  * What fills one placement, re-exported from `@snowcone-app/mockup-url`:
303
305
  * - a bare `string` → an image URL (shorthand for `{ src }`),
@@ -364,7 +366,7 @@ interface GetMockupUrlOptions {
364
366
  * verifies it.
365
367
  */
366
368
  secret?: string;
367
- /** Override the public host. Default: `https://img.snowcone.app`. */
369
+ /** Override the public host. Default: `SNOWCONE_HOSTS.img`. */
368
370
  base?: string;
369
371
  /**
370
372
  * Render width in px. Snaps DOWN to the nearest allowed size
@@ -382,12 +384,17 @@ interface GetMockupUrlOptions {
382
384
  /** Specific placement label override (only meaningful with a single `asset`). */
383
385
  placement?: string;
384
386
  /**
385
- * Center-crop of the mockup scene. `"2:3"` crops to portrait. `"16:9"` (or
386
- * omitting it) applies NO crop: the image keeps the scene's native shape —
387
- * 16:9 for most products, square for some — so don't assume the output
388
- * dimensions; measure or crop client-side with `object-fit: cover`.
387
+ * The picture's shape (MOCKUP_ASPECTS). `"16:9"` (or omitting it) is the mockup's default picture; `"2:3"` the
388
+ * centre portrait. Other shapes (`"9:16"`, `"1:1"`, `"app-header"`, …) come only from mockups made for them; a mockup
389
+ * that doesn't hold one answers E_MOCKUP_SHAPE_UNAVAILABLE with its list. Don't assume output dimensions: measure.
389
390
  */
390
- aspect?: "16:9" | "2:3";
391
+ aspect?: MockupAspect;
392
+ /**
393
+ * A platform preset (`"tiktok"`, `"instagram-feed"`, `"pinterest"`, `"app-header"`, … : MOCKUP_PRESETS in
394
+ * @snowcone-app/mockup-url): sets `aspect` and `width` for that platform. An explicit `width` wins; an `aspect` that
395
+ * disagrees throws (E_PRESET_ASPECT_CONFLICT). Never in the URL: two presets of one shape share one cached image.
396
+ */
397
+ preset?: MockupPreset;
391
398
  /**
392
399
  * Background color painted behind the mockup (6-hex, `#` optional — e.g.
393
400
  * `"f5f0ea"` or `"#F5F0EA"`), or `"transparent"` to force the raw cutout by
@@ -417,7 +424,7 @@ interface GetMockupUrlOptions {
417
424
  declare function getMockupUrl(productCode: string, opts: GetMockupUrlOptions): string;
418
425
  declare function getMockupUrl(assetUrl: string, productCode: string, opts: GetMockupUrlOptions): string;
419
426
  /** Default public host for the hosted buy page. */
420
- declare const DEFAULT_BUY_BASE = "https://buy.snowcone.app";
427
+ declare const DEFAULT_BUY_BASE: string;
421
428
  /**
422
429
  * Build the hosted buy-page URL — the checkout counterpart of
423
430
  * {@link getMockupUrl}. Same wire grammar, same options shape, different host:
@@ -1023,7 +1030,7 @@ type UserSelection = Record<string, string>;
1023
1030
  * Config for the pure URL builder: the two things not on MockupGenerationOptions.
1024
1031
  */
1025
1032
  interface BuildMockupUrlConfig {
1026
- /** Base of the public-image RESOLVER, e.g. https://img.snowcone.app (it
1033
+ /** Base of the public-image RESOLVER, e.g. `SNOWCONE_HOSTS.img` (it
1027
1034
  * seals the URL and 302s to the renderer). NOT the renderer host. */
1028
1035
  mockupBaseUrl: string;
1029
1036
  /** The shop's public Shop ID (= shop.id). */
@@ -2802,7 +2809,7 @@ declare function createSvelteComponent(descriptor: ComponentDescriptor, svelte:
2802
2809
  * `wss://WS_URL_NOT_CONFIGURED.invalid/realtime` placeholder so a 3rd party
2803
2810
  * can find the endpoint from the package alone (ADR-0079, Phase 2).
2804
2811
  */
2805
- declare const REALTIME_WS_URL = "wss://cdn.snowcone.app/realtime";
2812
+ declare const REALTIME_WS_URL: string;
2806
2813
 
2807
2814
  /**
2808
2815
  * Realtime grant helpers (ADR-0079, Phase 2).
@@ -2824,7 +2831,7 @@ interface RealtimeGrant {
2824
2831
  expiresAt: number;
2825
2832
  }
2826
2833
  /** Default backend base URL hosting `POST /realtime/grant`. */
2827
- declare const DEFAULT_GRANT_BASE = "https://api.snowcone.app";
2834
+ declare const DEFAULT_GRANT_BASE: string;
2828
2835
  /**
2829
2836
  * SERVER-SIDE: mint a realtime grant with a secret API key (sk_). Call this
2830
2837
  * from YOUR backend — never the browser; the API key must stay secret. The key
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { createDevFetcher } from './dev-fetcher.js';
2
- import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-url';
2
+ import { PublicDesign, PublicFill, PublicOptions, MockupAspect, MockupPreset } from '@snowcone-app/mockup-url';
3
+ export { SNOWCONE_HOSTS, SNOWCONE_REALTIME_WS_URL, SnowconeHostRole } from '@snowcone-app/mockup-url';
3
4
  export { GalleryReason, GalleryStanding, MockupRole, OrdinaryMockups, PDP_GALLERY_LIMIT, SIZE_PICTURE, gallerySizePicture, galleryStanding, mockupRole, ordinaryMockups, pictureForVariant, primaryMockup } from './mockup-role.js';
4
5
  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';
5
6
  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';
@@ -238,8 +239,9 @@ interface ProductSpec {
238
239
  interface Effects {
239
240
  grain?: 1 | 2;
240
241
  }
241
- /** Supported aspect ratios */
242
- type AspectRatio = '16:9' | '2:3';
242
+ /** Picture shapes (`aspect=`): the same list as @snowcone-app/mockup-url MOCKUP_ASPECTS. A mockup gives 16:9 + 2:3,
243
+ * or the shapes its plate holds; asking another answers E_MOCKUP_SHAPE_UNAVAILABLE with its list. */
244
+ type AspectRatio = '16:9' | '2:3' | '3:4' | '4:5' | '1:1' | '1.91:1' | '9:16' | '21:9' | 'app-header';
243
245
  /**
244
246
  * Blend configuration for mockup masks
245
247
  * Controls how artwork blends with the background texture
@@ -297,7 +299,7 @@ interface RateLimitState {
297
299
  }
298
300
 
299
301
  /** Default public host for the image-CDN model (ADR-0076). */
300
- declare const DEFAULT_MOCKUP_BASE = "https://img.snowcone.app";
302
+ declare const DEFAULT_MOCKUP_BASE: string;
301
303
  /**
302
304
  * What fills one placement, re-exported from `@snowcone-app/mockup-url`:
303
305
  * - a bare `string` → an image URL (shorthand for `{ src }`),
@@ -364,7 +366,7 @@ interface GetMockupUrlOptions {
364
366
  * verifies it.
365
367
  */
366
368
  secret?: string;
367
- /** Override the public host. Default: `https://img.snowcone.app`. */
369
+ /** Override the public host. Default: `SNOWCONE_HOSTS.img`. */
368
370
  base?: string;
369
371
  /**
370
372
  * Render width in px. Snaps DOWN to the nearest allowed size
@@ -382,12 +384,17 @@ interface GetMockupUrlOptions {
382
384
  /** Specific placement label override (only meaningful with a single `asset`). */
383
385
  placement?: string;
384
386
  /**
385
- * Center-crop of the mockup scene. `"2:3"` crops to portrait. `"16:9"` (or
386
- * omitting it) applies NO crop: the image keeps the scene's native shape —
387
- * 16:9 for most products, square for some — so don't assume the output
388
- * dimensions; measure or crop client-side with `object-fit: cover`.
387
+ * The picture's shape (MOCKUP_ASPECTS). `"16:9"` (or omitting it) is the mockup's default picture; `"2:3"` the
388
+ * centre portrait. Other shapes (`"9:16"`, `"1:1"`, `"app-header"`, …) come only from mockups made for them; a mockup
389
+ * that doesn't hold one answers E_MOCKUP_SHAPE_UNAVAILABLE with its list. Don't assume output dimensions: measure.
389
390
  */
390
- aspect?: "16:9" | "2:3";
391
+ aspect?: MockupAspect;
392
+ /**
393
+ * A platform preset (`"tiktok"`, `"instagram-feed"`, `"pinterest"`, `"app-header"`, … : MOCKUP_PRESETS in
394
+ * @snowcone-app/mockup-url): sets `aspect` and `width` for that platform. An explicit `width` wins; an `aspect` that
395
+ * disagrees throws (E_PRESET_ASPECT_CONFLICT). Never in the URL: two presets of one shape share one cached image.
396
+ */
397
+ preset?: MockupPreset;
391
398
  /**
392
399
  * Background color painted behind the mockup (6-hex, `#` optional — e.g.
393
400
  * `"f5f0ea"` or `"#F5F0EA"`), or `"transparent"` to force the raw cutout by
@@ -417,7 +424,7 @@ interface GetMockupUrlOptions {
417
424
  declare function getMockupUrl(productCode: string, opts: GetMockupUrlOptions): string;
418
425
  declare function getMockupUrl(assetUrl: string, productCode: string, opts: GetMockupUrlOptions): string;
419
426
  /** Default public host for the hosted buy page. */
420
- declare const DEFAULT_BUY_BASE = "https://buy.snowcone.app";
427
+ declare const DEFAULT_BUY_BASE: string;
421
428
  /**
422
429
  * Build the hosted buy-page URL — the checkout counterpart of
423
430
  * {@link getMockupUrl}. Same wire grammar, same options shape, different host:
@@ -1023,7 +1030,7 @@ type UserSelection = Record<string, string>;
1023
1030
  * Config for the pure URL builder: the two things not on MockupGenerationOptions.
1024
1031
  */
1025
1032
  interface BuildMockupUrlConfig {
1026
- /** Base of the public-image RESOLVER, e.g. https://img.snowcone.app (it
1033
+ /** Base of the public-image RESOLVER, e.g. `SNOWCONE_HOSTS.img` (it
1027
1034
  * seals the URL and 302s to the renderer). NOT the renderer host. */
1028
1035
  mockupBaseUrl: string;
1029
1036
  /** The shop's public Shop ID (= shop.id). */
@@ -2802,7 +2809,7 @@ declare function createSvelteComponent(descriptor: ComponentDescriptor, svelte:
2802
2809
  * `wss://WS_URL_NOT_CONFIGURED.invalid/realtime` placeholder so a 3rd party
2803
2810
  * can find the endpoint from the package alone (ADR-0079, Phase 2).
2804
2811
  */
2805
- declare const REALTIME_WS_URL = "wss://cdn.snowcone.app/realtime";
2812
+ declare const REALTIME_WS_URL: string;
2806
2813
 
2807
2814
  /**
2808
2815
  * Realtime grant helpers (ADR-0079, Phase 2).
@@ -2824,7 +2831,7 @@ interface RealtimeGrant {
2824
2831
  expiresAt: number;
2825
2832
  }
2826
2833
  /** Default backend base URL hosting `POST /realtime/grant`. */
2827
- declare const DEFAULT_GRANT_BASE = "https://api.snowcone.app";
2834
+ declare const DEFAULT_GRANT_BASE: string;
2828
2835
  /**
2829
2836
  * SERVER-SIDE: mint a realtime grant with a secret API key (sk_). Call this
2830
2837
  * from YOUR backend — never the browser; the API key must stay secret. The key
package/dist/index.js CHANGED
@@ -1,17 +1,19 @@
1
1
  import {
2
2
  REALTIME_WS_URL,
3
3
  RealtimeMockupService
4
- } from "./chunk-4FZOZLWF.js";
4
+ } from "./chunk-KMDKCI4T.js";
5
5
  import {
6
6
  createDevFetcher
7
7
  } from "./chunk-7VO4EL2V.js";
8
8
  import {
9
+ SNOWCONE_HOSTS,
10
+ SNOWCONE_REALTIME_WS_URL,
9
11
  buildMockupUrl,
10
12
  buildPublicMockupUrl,
11
13
  canonicalForSig,
12
14
  normalizeDesignElements,
13
15
  normalizeWidth
14
- } from "./chunk-ZBJBBIH3.js";
16
+ } from "./chunk-O6I5SJT5.js";
15
17
  import {
16
18
  PDP_GALLERY_LIMIT,
17
19
  SIZE_PICTURE,
@@ -213,8 +215,8 @@ var SignatureCache = class {
213
215
  };
214
216
 
215
217
  // src/mockup/service.ts
216
- var DEFAULT_IMAGE_URL = typeof process !== "undefined" && process.env?.SNOWCONE_IMAGE_URL || "https://cdn.snowcone.app";
217
- var DEFAULT_SIGNER_URL = typeof process !== "undefined" && process.env?.SNOWCONE_SIGNER_URL || "https://s.snowcone.app/sign";
218
+ var DEFAULT_IMAGE_URL = typeof process !== "undefined" && process.env?.SNOWCONE_IMAGE_URL || SNOWCONE_HOSTS.cdn;
219
+ var DEFAULT_SIGNER_URL = typeof process !== "undefined" && process.env?.SNOWCONE_SIGNER_URL || `${SNOWCONE_HOSTS.sign}/sign`;
218
220
  var RATE_LIMIT_PER_MINUTE = 450;
219
221
  var RATE_LIMIT_PER_SECOND = 20;
220
222
  var MockupServiceImpl = class {
@@ -548,7 +550,7 @@ function hmacSha256Hex(secret, message) {
548
550
  }
549
551
 
550
552
  // src/mockup/getMockupUrl.ts
551
- var DEFAULT_MOCKUP_BASE = "https://img.snowcone.app";
553
+ var DEFAULT_MOCKUP_BASE = SNOWCONE_HOSTS.img;
552
554
  function getMockupUrl(a, b, c) {
553
555
  let productCode;
554
556
  let opts;
@@ -577,6 +579,7 @@ function getMockupUrl(a, b, c) {
577
579
  ...opts.options ? { options: opts.options } : {},
578
580
  ...opts.width !== void 0 ? { width: opts.width } : {},
579
581
  ...opts.aspect !== void 0 ? { aspect: opts.aspect } : {},
582
+ ...opts.preset !== void 0 ? { preset: opts.preset } : {},
580
583
  ...opts.bg !== void 0 ? { bg: opts.bg } : {},
581
584
  ...opts.mockup ?? opts.view ? { mockup: opts.mockup ?? opts.view } : {},
582
585
  ...opts.variant !== void 0 ? { variant: opts.variant } : {},
@@ -588,7 +591,7 @@ function getMockupUrl(a, b, c) {
588
591
  const signature = hmacSha256Hex(opts.secret, canonicalForSig(url)).slice(0, 16);
589
592
  return `${url}&signature=${signature}`;
590
593
  }
591
- var DEFAULT_BUY_BASE = "https://buy.snowcone.app";
594
+ var DEFAULT_BUY_BASE = SNOWCONE_HOSTS.buy;
592
595
  function getBuyUrl(productCode, opts) {
593
596
  return getMockupUrl(productCode, {
594
597
  ...opts,
@@ -1464,7 +1467,7 @@ function buildMockupUrl2(options, cfg) {
1464
1467
  }
1465
1468
  function resolveMockupBaseUrl() {
1466
1469
  const winConfig = typeof window !== "undefined" && window.snowcone || {};
1467
- return winConfig.resolver || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MOCKUP_RESOLVER_URL || typeof process !== "undefined" && process.env?.SNOWCONE_IMAGE_URL || "https://img.snowcone.app";
1470
+ return winConfig.resolver || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MOCKUP_RESOLVER_URL || typeof process !== "undefined" && process.env?.SNOWCONE_IMAGE_URL || SNOWCONE_HOSTS.img;
1468
1471
  }
1469
1472
  function resolveShop() {
1470
1473
  const winConfig = typeof window !== "undefined" && window.snowcone || {};
@@ -4599,7 +4602,7 @@ function createSvelteComponent(descriptor, svelte) {
4599
4602
  }
4600
4603
 
4601
4604
  // src/realtime/grant.ts
4602
- var DEFAULT_GRANT_BASE = "https://api.snowcone.app";
4605
+ var DEFAULT_GRANT_BASE = SNOWCONE_HOSTS.api;
4603
4606
  async function mintRealtimeGrant(opts) {
4604
4607
  const f = opts.fetch ?? globalThis.fetch;
4605
4608
  const headers = { "Content-Type": "application/json" };
@@ -5083,7 +5086,7 @@ function validateProductLoose(product) {
5083
5086
  }
5084
5087
  async function listProducts(config) {
5085
5088
  const f = getFetcher(config);
5086
- const meilisearchHost = config?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
5089
+ const meilisearchHost = config?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || SNOWCONE_HOSTS.search;
5087
5090
  const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
5088
5091
  const meilisearchIndex = config?.meilisearch?.index || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_INDEX || "snowcone";
5089
5092
  const headers = {
@@ -5109,7 +5112,7 @@ async function listProducts(config) {
5109
5112
  }
5110
5113
  async function getProduct(idOrSlug, config) {
5111
5114
  const f = getFetcher(config);
5112
- const meilisearchHost = config?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
5115
+ const meilisearchHost = config?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || SNOWCONE_HOSTS.search;
5113
5116
  const meilisearchApiKey = config?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
5114
5117
  const meilisearchIndex = config?.meilisearch?.index || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_INDEX || "snowcone";
5115
5118
  const headers = {
@@ -5133,7 +5136,7 @@ async function getProduct(idOrSlug, config) {
5133
5136
  }
5134
5137
  async function searchDesigns(query = "", options) {
5135
5138
  const f = getFetcher(options);
5136
- const meilisearchHost = options?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
5139
+ const meilisearchHost = options?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || SNOWCONE_HOSTS.search;
5137
5140
  const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
5138
5141
  const designsIndex = options?.meilisearch?.designsIndex || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX || "snowcone-designs";
5139
5142
  const headers = {
@@ -5219,6 +5222,8 @@ export {
5219
5222
  RealtimeMockupService,
5220
5223
  RenderSession,
5221
5224
  SIZE_PICTURE,
5225
+ SNOWCONE_HOSTS,
5226
+ SNOWCONE_REALTIME_WS_URL,
5222
5227
  SnowconeSdkError,
5223
5228
  StandardComponents,
5224
5229
  StandardEvents,
package/dist/react.cjs CHANGED
@@ -32,8 +32,136 @@ module.exports = __toCommonJS(react_exports);
32
32
  // src/realtime/react.ts
33
33
  var import_react = require("react");
34
34
 
35
+ // ../mockup-url/src/index.ts
36
+ var SNOWCONE_HOSTS = {
37
+ /** REST API: shops, orders, AI generation, realtime grants. */
38
+ api: "https://api.snowcone.app",
39
+ /** Public mockup-image resolver (`/{productCode}?shop=…&asset=…`). */
40
+ img: "https://img.snowcone.app",
41
+ /** Hosted buy page (same grammar as `img`, opens checkout). */
42
+ buy: "https://buy.snowcone.app",
43
+ /** Public product / designs catalog (Meilisearch-compatible). */
44
+ search: "https://search.snowcone.app",
45
+ /** Render CDN — signed render URLs and the realtime socket. */
46
+ cdn: "https://cdn.snowcone.app",
47
+ /** Legacy URL signer. */
48
+ sign: "https://s.snowcone.app",
49
+ /** Content-addressed artwork store (ingest handles). */
50
+ raws: "https://raws.snowcone.app",
51
+ /** Developer docs. */
52
+ docs: "https://developers.snowcone.app",
53
+ /** The storefront site; `/api/launch` says whether orders are open yet. */
54
+ site: "https://snowcone.app",
55
+ /** The hosted MCP endpoint; it also serves the photo upload page (`/upload/<token>`). */
56
+ mcp: "https://mcp.snowcone.app",
57
+ /** Where draft designs made for a search are stored (a draft's `image_url`). */
58
+ drafts: "https://agentdraft.storage.snowcone.app"
59
+ };
60
+ var SNOWCONE_REALTIME_WS_URL = `${SNOWCONE_HOSTS.cdn.replace(/^http/, "ws")}/realtime`;
61
+ var PARAMS = {
62
+ shop: "shop",
63
+ asset: "asset",
64
+ assets: "assets",
65
+ /**
66
+ * Render a catalog design by reference (ADR-0086): `design=<pairingId|slug>`.
67
+ * The resolver looks the design up in the public `snowcone-designs` index
68
+ * (membership = license) and injects its asset components server-side, so no
69
+ * raw asset URL crosses the wire and no origin allowlisting is involved.
70
+ * Catalog renders are FREE — mutually exclusive with `asset`/`asset.<key>`/
71
+ * `color.<key>` (free = the design as published).
72
+ */
73
+ design: "design",
74
+ placement: "placement",
75
+ /**
76
+ * Album page selector (ADR-0086 §5): `page=N` (positive integer) picks which
77
+ * page/spread of an album product a mockup renders. Only valid on products
78
+ * whose catalog entry carries an `album` block — the edge resolver maps page
79
+ * N onto the repeating page placement (`page_N` → the geometry of
80
+ * `album.pagePlacement`); the catalog never enumerates `page_1…page_100` and
81
+ * the render server is unchanged.
82
+ */
83
+ page: "page",
84
+ variant: "variant",
85
+ mockup: "mockup",
86
+ width: "width",
87
+ grain: "grain",
88
+ aspect: "aspect",
89
+ /**
90
+ * Background color (6-hex, no '#') painted behind the mockup — visible only
91
+ * where the mockup itself has transparency (studio-cutout shots) — or the
92
+ * reserved `transparent` token, which suppresses the shop default for this
93
+ * one render. Absent = the shop's configured default, else transparent.
94
+ */
95
+ bg: "bg",
96
+ /** Live preview/calibration mask overrides (not cached). */
97
+ maskOverrides: "maskOverrides",
98
+ /**
99
+ * Render-only option picks (the `affectsCombinations:false` attributes), as a
100
+ * base64 JSON map `{ attributeName: choiceLabel }`. The render server already parses
101
+ * this and resolves per-choice underlays from it; the builder emits it so the
102
+ * edge resolver can forward render-only picks (e.g. a cap's Crown/Strap color)
103
+ * without changing the server grammar.
104
+ */
105
+ optionSelections: "optionSelections",
106
+ signature: "signature",
107
+ seal: "seal"
108
+ };
109
+ var MOCKUP_PRESETS = {
110
+ tiktok: { aspect: "9:16", width: 1200 },
111
+ // 1080x1920
112
+ "instagram-story": { aspect: "9:16", width: 1200 },
113
+ // 1080x1920 (and Reels)
114
+ "youtube-shorts": { aspect: "9:16", width: 1200 },
115
+ // 1080x1920
116
+ "instagram-feed": { aspect: "4:5", width: 1200 },
117
+ // 1080x1350
118
+ "instagram-square": { aspect: "1:1", width: 1200 },
119
+ // 1080x1080
120
+ "facebook-feed": { aspect: "4:5", width: 1200 },
121
+ // 1080x1350
122
+ "facebook-link": { aspect: "1.91:1", width: 1200 },
123
+ // 1200x628
124
+ "linkedin-link": { aspect: "1.91:1", width: 1200 },
125
+ // 1200x627
126
+ pinterest: { aspect: "2:3", width: 1e3 },
127
+ // 1000x1500
128
+ "youtube-thumbnail": { aspect: "16:9", width: 1400 },
129
+ // 1280x720
130
+ "x-post": { aspect: "16:9", width: 1600 },
131
+ // 1600x900
132
+ amazon: { aspect: "1:1", width: 2e3 },
133
+ // 2000x2000 main image
134
+ etsy: { aspect: "1:1", width: 2e3 },
135
+ // 2000x2000
136
+ shopify: { aspect: "1:1", width: 2e3 },
137
+ // 2048x2048 product image, nearest rung
138
+ "site-hero": { aspect: "16:9", width: 2500 },
139
+ // 2560x1440
140
+ "web-banner": { aspect: "21:9", width: 2500 },
141
+ // ultra-wide banner
142
+ "app-header": { aspect: "app-header", width: 1200 }
143
+ // the hero under a phone's status bar (8:9)
144
+ };
145
+ var MOCKUP_PRESET_NAMES = Object.keys(MOCKUP_PRESETS);
146
+ var MAX_RENDER_URL_LENGTH = 12 * 1024;
147
+ var INGEST_HANDLE_BASE = `${SNOWCONE_HOSTS.raws}/art-ingest/`;
148
+ var DEFAULT_PUBLIC_BASE_URL = SNOWCONE_HOSTS.img;
149
+ var PUBLIC_PARAM_NAMES = [
150
+ PARAMS.asset,
151
+ PARAMS.design,
152
+ PARAMS.shop,
153
+ PARAMS.placement,
154
+ PARAMS.page,
155
+ PARAMS.variant,
156
+ PARAMS.mockup,
157
+ PARAMS.width,
158
+ PARAMS.aspect,
159
+ PARAMS.bg,
160
+ PARAMS.signature
161
+ ];
162
+
35
163
  // src/realtime/constants.ts
36
- var REALTIME_WS_URL = "wss://cdn.snowcone.app/realtime";
164
+ var REALTIME_WS_URL = SNOWCONE_REALTIME_WS_URL;
37
165
 
38
166
  // src/realtime/websocket.ts
39
167
  function pruneUndefined(obj) {
@@ -1024,7 +1152,7 @@ ${versionToSend}
1024
1152
  };
1025
1153
 
1026
1154
  // src/realtime/react.ts
1027
- var DEFAULT_REALTIME_WS_URL = "wss://cdn.snowcone.app/realtime";
1155
+ var DEFAULT_REALTIME_WS_URL = REALTIME_WS_URL;
1028
1156
  function useRealtimeMockup(options = {}) {
1029
1157
  const wsUrl = options.wsUrl ?? (options.getToken ? DEFAULT_REALTIME_WS_URL : void 0);
1030
1158
  const serviceRef = (0, import_react.useRef)(null);
package/dist/react.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
+ REALTIME_WS_URL,
2
3
  RealtimeMockupService
3
- } from "./chunk-4FZOZLWF.js";
4
+ } from "./chunk-KMDKCI4T.js";
5
+ import "./chunk-O6I5SJT5.js";
4
6
 
5
7
  // src/realtime/react.ts
6
8
  import { useCallback, useEffect, useRef, useState } from "react";
7
- var DEFAULT_REALTIME_WS_URL = "wss://cdn.snowcone.app/realtime";
9
+ var DEFAULT_REALTIME_WS_URL = REALTIME_WS_URL;
8
10
  function useRealtimeMockup(options = {}) {
9
11
  const wsUrl = options.wsUrl ?? (options.getToken ? DEFAULT_REALTIME_WS_URL : void 0);
10
12
  const serviceRef = useRef(null);
package/dist/server.cjs CHANGED
@@ -32,6 +32,31 @@ __export(server_exports, {
32
32
  module.exports = __toCommonJS(server_exports);
33
33
 
34
34
  // ../mockup-url/src/index.ts
35
+ var SNOWCONE_HOSTS = {
36
+ /** REST API: shops, orders, AI generation, realtime grants. */
37
+ api: "https://api.snowcone.app",
38
+ /** Public mockup-image resolver (`/{productCode}?shop=…&asset=…`). */
39
+ img: "https://img.snowcone.app",
40
+ /** Hosted buy page (same grammar as `img`, opens checkout). */
41
+ buy: "https://buy.snowcone.app",
42
+ /** Public product / designs catalog (Meilisearch-compatible). */
43
+ search: "https://search.snowcone.app",
44
+ /** Render CDN — signed render URLs and the realtime socket. */
45
+ cdn: "https://cdn.snowcone.app",
46
+ /** Legacy URL signer. */
47
+ sign: "https://s.snowcone.app",
48
+ /** Content-addressed artwork store (ingest handles). */
49
+ raws: "https://raws.snowcone.app",
50
+ /** Developer docs. */
51
+ docs: "https://developers.snowcone.app",
52
+ /** The storefront site; `/api/launch` says whether orders are open yet. */
53
+ site: "https://snowcone.app",
54
+ /** The hosted MCP endpoint; it also serves the photo upload page (`/upload/<token>`). */
55
+ mcp: "https://mcp.snowcone.app",
56
+ /** Where draft designs made for a search are stored (a draft's `image_url`). */
57
+ drafts: "https://agentdraft.storage.snowcone.app"
58
+ };
59
+ var SNOWCONE_REALTIME_WS_URL = `${SNOWCONE_HOSTS.cdn.replace(/^http/, "ws")}/realtime`;
35
60
  var PARAMS = {
36
61
  shop: "shop",
37
62
  asset: "asset",
@@ -80,7 +105,46 @@ var PARAMS = {
80
105
  signature: "signature",
81
106
  seal: "seal"
82
107
  };
108
+ var MOCKUP_PRESETS = {
109
+ tiktok: { aspect: "9:16", width: 1200 },
110
+ // 1080x1920
111
+ "instagram-story": { aspect: "9:16", width: 1200 },
112
+ // 1080x1920 (and Reels)
113
+ "youtube-shorts": { aspect: "9:16", width: 1200 },
114
+ // 1080x1920
115
+ "instagram-feed": { aspect: "4:5", width: 1200 },
116
+ // 1080x1350
117
+ "instagram-square": { aspect: "1:1", width: 1200 },
118
+ // 1080x1080
119
+ "facebook-feed": { aspect: "4:5", width: 1200 },
120
+ // 1080x1350
121
+ "facebook-link": { aspect: "1.91:1", width: 1200 },
122
+ // 1200x628
123
+ "linkedin-link": { aspect: "1.91:1", width: 1200 },
124
+ // 1200x627
125
+ pinterest: { aspect: "2:3", width: 1e3 },
126
+ // 1000x1500
127
+ "youtube-thumbnail": { aspect: "16:9", width: 1400 },
128
+ // 1280x720
129
+ "x-post": { aspect: "16:9", width: 1600 },
130
+ // 1600x900
131
+ amazon: { aspect: "1:1", width: 2e3 },
132
+ // 2000x2000 main image
133
+ etsy: { aspect: "1:1", width: 2e3 },
134
+ // 2000x2000
135
+ shopify: { aspect: "1:1", width: 2e3 },
136
+ // 2048x2048 product image, nearest rung
137
+ "site-hero": { aspect: "16:9", width: 2500 },
138
+ // 2560x1440
139
+ "web-banner": { aspect: "21:9", width: 2500 },
140
+ // ultra-wide banner
141
+ "app-header": { aspect: "app-header", width: 1200 }
142
+ // the hero under a phone's status bar (8:9)
143
+ };
144
+ var MOCKUP_PRESET_NAMES = Object.keys(MOCKUP_PRESETS);
83
145
  var MAX_RENDER_URL_LENGTH = 12 * 1024;
146
+ var INGEST_HANDLE_BASE = `${SNOWCONE_HOSTS.raws}/art-ingest/`;
147
+ var DEFAULT_PUBLIC_BASE_URL = SNOWCONE_HOSTS.img;
84
148
  var PUBLIC_PARAM_NAMES = [
85
149
  PARAMS.asset,
86
150
  PARAMS.design,
@@ -202,7 +266,7 @@ async function signGrantRequest(shop, secret) {
202
266
  return { shop, ts, signature };
203
267
  }
204
268
  function createRealtimeGrantHandler(opts) {
205
- const base = opts.base ?? "https://api.snowcone.app";
269
+ const base = opts.base ?? SNOWCONE_HOSTS.api;
206
270
  return async function POST(req) {
207
271
  if (opts.gate) {
208
272
  const result = await opts.gate(req);
@@ -422,7 +486,7 @@ function createImageSearchHandler(opts) {
422
486
  }
423
487
  var BG_REMOVE_MAX_URL_LENGTH = 2048;
424
488
  function createBgRemoveHandler(opts) {
425
- const base = opts.base ?? "https://api.snowcone.app";
489
+ const base = opts.base ?? SNOWCONE_HOSTS.api;
426
490
  return async function POST(req) {
427
491
  if (opts.gate) {
428
492
  const result = await opts.gate(req);
package/dist/server.d.cts CHANGED
@@ -78,7 +78,7 @@ interface RealtimeGrantHandlerOptions {
78
78
  secret: string;
79
79
  /** The shop to mint grants for (= shop.id). */
80
80
  shop: string;
81
- /** Backend base URL hosting `POST /realtime/grant`. Default api.snowcone.app. */
81
+ /** Backend base URL hosting `POST /realtime/grant`. Default `SNOWCONE_HOSTS.api`. */
82
82
  base?: string;
83
83
  /** Optional gate (auth / rate-limit) run before minting. */
84
84
  gate?: SignGate;
@@ -174,7 +174,7 @@ interface BgRemoveHandlerOptions {
174
174
  * Server-only — the browser only ever sees this route. Required.
175
175
  */
176
176
  shopKey: string;
177
- /** Backend base URL hosting `POST /ai-generations/remove-background`. Default api.snowcone.app. */
177
+ /** Backend base URL hosting `POST /ai-generations/remove-background`. Default `SNOWCONE_HOSTS.api`. */
178
178
  base?: string;
179
179
  /** Optional auth / rate-limit / bot check, same SignGate type as the other handlers. */
180
180
  gate?: SignGate;
package/dist/server.d.ts CHANGED
@@ -78,7 +78,7 @@ interface RealtimeGrantHandlerOptions {
78
78
  secret: string;
79
79
  /** The shop to mint grants for (= shop.id). */
80
80
  shop: string;
81
- /** Backend base URL hosting `POST /realtime/grant`. Default api.snowcone.app. */
81
+ /** Backend base URL hosting `POST /realtime/grant`. Default `SNOWCONE_HOSTS.api`. */
82
82
  base?: string;
83
83
  /** Optional gate (auth / rate-limit) run before minting. */
84
84
  gate?: SignGate;
@@ -174,7 +174,7 @@ interface BgRemoveHandlerOptions {
174
174
  * Server-only — the browser only ever sees this route. Required.
175
175
  */
176
176
  shopKey: string;
177
- /** Backend base URL hosting `POST /ai-generations/remove-background`. Default api.snowcone.app. */
177
+ /** Backend base URL hosting `POST /ai-generations/remove-background`. Default `SNOWCONE_HOSTS.api`. */
178
178
  base?: string;
179
179
  /** Optional auth / rate-limit / bot check, same SignGate type as the other handlers. */
180
180
  gate?: SignGate;
package/dist/server.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import {
2
+ SNOWCONE_HOSTS,
2
3
  canonicalForSig,
3
4
  signDevSig
4
- } from "./chunk-ZBJBBIH3.js";
5
+ } from "./chunk-O6I5SJT5.js";
5
6
 
6
7
  // src/server.ts
7
8
  function json(body, status = 200) {
@@ -59,7 +60,7 @@ async function signGrantRequest(shop, secret) {
59
60
  return { shop, ts, signature };
60
61
  }
61
62
  function createRealtimeGrantHandler(opts) {
62
- const base = opts.base ?? "https://api.snowcone.app";
63
+ const base = opts.base ?? SNOWCONE_HOSTS.api;
63
64
  return async function POST(req) {
64
65
  if (opts.gate) {
65
66
  const result = await opts.gate(req);
@@ -279,7 +280,7 @@ function createImageSearchHandler(opts) {
279
280
  }
280
281
  var BG_REMOVE_MAX_URL_LENGTH = 2048;
281
282
  function createBgRemoveHandler(opts) {
282
- const base = opts.base ?? "https://api.snowcone.app";
283
+ const base = opts.base ?? SNOWCONE_HOSTS.api;
283
284
  return async function POST(req) {
284
285
  if (opts.gate) {
285
286
  const result = await opts.gate(req);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowcone-app/sdk",
3
- "version": "0.29.1",
3
+ "version": "0.31.0",
4
4
  "description": "Snowcone SDK for product mockups and print-on-demand",
5
5
  "keywords": [
6
6
  "merch",
@@ -91,7 +91,7 @@
91
91
  "tsup": "^8.1.0",
92
92
  "typescript": "^5.5.4",
93
93
  "vitest": "^2.1.9",
94
- "@snowcone-app/mockup-url": "0.6.0"
94
+ "@snowcone-app/mockup-url": "0.6.1"
95
95
  },
96
96
  "engines": {
97
97
  "node": ">=18"