@snowcone-app/sdk 0.11.0 → 0.12.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,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#620](https://github.com/snowcone-app/snowcone-monorepo/pull/620) [`8fee313`](https://github.com/snowcone-app/snowcone-monorepo/commit/8fee31335d0d315834e9b7f6602404a94eeda5b7) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Composable `Editor.*` primitives — the ADR-0085 vertical slice (experimental).
8
+
9
+ New on `@snowcone-app/canvas/embed`: `Editor.Root` / `Editor.Canvas` /
10
+ `Editor.Preview` / `Editor.TextField` / `Editor.Buy` — compound parts over one
11
+ Root; the host owns all layout. Includes the typed layer-token API
12
+ (`design.layer("name")` — compile-checked against the design's layer names,
13
+ runtime-validated for JSON-loaded designs), the one live design-state store
14
+ (seeded from the design, updated by canvas edits AND TextField writes,
15
+ last-write-wins), smart Buy (completeness rules + payload assembled from
16
+ design state), structured `EditorError` codes, and Root's built-in error
17
+ boundary. **All `Editor.*` exports are `@experimental`** — the API may change
18
+ in minors until the default editor is rebuilt from these public parts.
19
+
20
+ Existing turnkey API unchanged in meaning: `RealtimeEmbed` is now a thin
21
+ wrapper over `Editor.Root` (same behavior, advisory validation),
22
+ `RealtimeMockup` over `Editor.Preview`. One behavior note: `RealtimeCanvas`'s
23
+ implementation moved into the shared lazy renderer chunk — the embed entry's
24
+ static import graph is now renderer-free (a no-canvas page never downloads
25
+ the rendering engine; CI-enforced), and the canvas mounts one chunk-fetch
26
+ after first paint. The floating contextual toolbar now tracks page/container
27
+ scroll (it previously drifted on scrolling host pages).
28
+
29
+ sdk: internal dead-code cleanup (no API change).
30
+
31
+ ## 0.12.0
32
+
33
+ ### Minor Changes
34
+
35
+ - [#598](https://github.com/snowcone-app/snowcone-monorepo/pull/598) [`2adb836`](https://github.com/snowcone-app/snowcone-monorepo/commit/2adb836ef477809747d64053d55a84cfa166df9a) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Remove `uploadAsset`, `mintUploadGrant`, and `fetchUploadGrant` (added in 0.11.0). The keyless upload-grant path was reversed (ADR-0084): a keyless, persistent write to shop storage is effectively an anonymous image host on our domain, a different trust class from keyless renders (which are ephemeral). Third-party uploads use the credentialed `POST /uploads/base64` path (`sk_` key, `uploads:write` scope); backend-less integrations pass a public image URL and let the renderer fetch it.
36
+
37
+ ### Patch Changes
38
+
39
+ - [#596](https://github.com/snowcone-app/snowcone-monorepo/pull/596) [`b04c995`](https://github.com/snowcone-app/snowcone-monorepo/commit/b04c995d0a115760341f8b51f1ecbfb01deb8d6b) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Point API-key management links at snowcone.app/studio/api-keys (the old /api-keys route is gone).
40
+
3
41
  ## 0.11.0
4
42
 
5
43
  ### Minor Changes
package/README.md CHANGED
@@ -181,7 +181,7 @@ clients. This is exactly how the Snowcone PDP renders mockups (see ADR-0079).
181
181
  Authorize the session with a short-lived **grant**. Mint it server-side with a
182
182
  secret API key (`sk_…`, scope `mockups:realtime`) so the key never reaches the
183
183
  browser. Create the key — and find your publishable `shop.id` — on the
184
- [API keys page](https://snowcone.app/api-keys):
184
+ [API keys page](https://snowcone.app/studio/api-keys):
185
185
 
186
186
  ```typescript
187
187
  // YOUR backend route, e.g. POST /api/realtime/grant
@@ -26,7 +26,6 @@ var RealtimeMockupService = class {
26
26
  logs = [];
27
27
  lastError = null;
28
28
  callbacks = {};
29
- lastBlobSentAt = 0;
30
29
  // Per-request send timestamps keyed by requestId, for client-observed
31
30
  // round-trip timing in the mockup_rendered log. Pruned to a small cap so an
32
31
  // in-flight burst can't grow it unbounded.
@@ -556,7 +555,6 @@ var RealtimeMockupService = class {
556
555
  });
557
556
  this.ws.send(message);
558
557
  this.recordRequestSent(requestId);
559
- this.lastBlobSentAt = Date.now();
560
558
  console.log(`[WS] canvas_state(ref) SENT: placement="${placement}" v${this.lastSentVersion} req=${requestId} stateId=${stateId} at ${Date.now()}`);
561
559
  this.addLog(`Sent canvas stateId "${stateId}" for "${placement}" (v${this.lastSentVersion}, req ${requestId})`, "sent");
562
560
  this.callbacks.onBlobSent?.(placement);
@@ -594,7 +592,6 @@ var RealtimeMockupService = class {
594
592
  this.ws.send(message);
595
593
  this.recordRequestSent(requestId);
596
594
  this.lastSentStateJson[placement] = stateJson;
597
- this.lastBlobSentAt = Date.now();
598
595
  console.log(`[WS] canvas_state SENT: placement="${placement}" v${this.lastSentVersion} req=${requestId} (${(message.length / 1024).toFixed(1)}KB) at ${Date.now()}`);
599
596
  this.addLog(`Sent canvas state for "${placement}" (${(message.length / 1024).toFixed(1)}KB, v${this.lastSentVersion}, req ${requestId})`, "sent");
600
597
  this.callbacks.onBlobSent?.(placement);
@@ -624,7 +621,6 @@ ${versionToSend}
624
621
  combined.set(imageBytes, headerBytes.length);
625
622
  }
626
623
  this.ws.send(combined.buffer);
627
- this.lastBlobSentAt = Date.now();
628
624
  this.addLog(`Sent canvas blob for placement "${placement}" (${imageBytes.length} bytes, v${versionToSend})`, "sent");
629
625
  if (notifyCallback) {
630
626
  this.callbacks.onBlobSent?.(placement);
package/dist/index.cjs CHANGED
@@ -42,7 +42,6 @@ __export(index_exports, {
42
42
  DEFAULT_GRANT_BASE: () => DEFAULT_GRANT_BASE,
43
43
  DEFAULT_MOCKUP_BASE: () => DEFAULT_MOCKUP_BASE,
44
44
  DEFAULT_PLACEMENT_DIMENSIONS: () => DEFAULT_PLACEMENT_DIMENSIONS,
45
- DEFAULT_UPLOAD_BASE: () => DEFAULT_UPLOAD_BASE,
46
45
  Elements: () => Elements,
47
46
  ErrorManager: () => ErrorManager,
48
47
  EventDelegator: () => EventDelegator,
@@ -104,7 +103,6 @@ __export(index_exports, {
104
103
  describeProductTitle: () => describeProductTitle,
105
104
  extractProductId: () => extractProductId,
106
105
  fetchRealtimeGrant: () => fetchRealtimeGrant,
107
- fetchUploadGrant: () => fetchUploadGrant,
108
106
  filterImagePlacements: () => filterImagePlacements,
109
107
  findBestCombination: () => findBestCombination,
110
108
  findClosestSnapPoint: () => findClosestSnapPoint,
@@ -130,7 +128,6 @@ __export(index_exports, {
130
128
  isValidTileCount: () => isValidTileCount,
131
129
  listProducts: () => listProducts,
132
130
  mintRealtimeGrant: () => mintRealtimeGrant,
133
- mintUploadGrant: () => mintUploadGrant,
134
131
  mockupUrl: () => mockupUrl,
135
132
  normalizeChoice: () => normalizeChoice,
136
133
  prepareOptionRenderData: () => prepareOptionRenderData,
@@ -142,7 +139,6 @@ __export(index_exports, {
142
139
  simulateCartOperation: () => simulateCartOperation,
143
140
  toCombinations: () => toCombinations,
144
141
  toOptionAttributes: () => toOptionAttributes,
145
- uploadAsset: () => uploadAsset,
146
142
  useVueAdapter: () => useFrameworkAdapter,
147
143
  validateAlignment: () => validateAlignment,
148
144
  validateDesignElement: () => validateDesignElement,
@@ -414,59 +410,6 @@ var MockupServiceImpl = class {
414
410
  }
415
411
  return url;
416
412
  }
417
- buildMockupUrl(options) {
418
- const { design, product, effects } = options;
419
- const pathSegments = ["m"];
420
- pathSegments.push(product.productId);
421
- pathSegments.push(product.mockupId);
422
- pathSegments.push(product.variantId);
423
- pathSegments.push(String(product.width));
424
- const designParts = [];
425
- for (const element of design) {
426
- const part = this.encodeDesignElement(element);
427
- designParts.push(part);
428
- }
429
- if (designParts.length > 0) {
430
- pathSegments.push(designParts.join("_"));
431
- } else {
432
- pathSegments.push("");
433
- }
434
- if (effects?.grain) {
435
- pathSegments.push(`g${effects.grain}`);
436
- }
437
- return "/" + pathSegments.join("/");
438
- }
439
- encodeDesignElement(element) {
440
- const parts = [];
441
- if (element.type === "image") {
442
- const encodedUrl = this.encodeImageUrl(element.imageUrl);
443
- parts.push(encodedUrl);
444
- parts.push(element.placement);
445
- parts.push(String(element.width));
446
- parts.push(String(element.height));
447
- parts.push(element.alignment);
448
- if (element.tiles && element.tiles > 1) {
449
- parts.push(`t${element.tiles}`);
450
- }
451
- } else if (element.type === "color") {
452
- const colorCode = element.hex.replace("#", "");
453
- parts.push(colorCode);
454
- parts.push(element.placement);
455
- parts.push(String(element.width));
456
- parts.push(String(element.height));
457
- parts.push(element.alignment);
458
- }
459
- return parts.join(",");
460
- }
461
- encodeImageUrl(url) {
462
- if (typeof window !== "undefined" && window.btoa) {
463
- const base64 = window.btoa(url);
464
- return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
465
- } else {
466
- const base64 = Buffer.from(url).toString("base64");
467
- return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
468
- }
469
- }
470
413
  async getSignedUrl(relativeUrl) {
471
414
  const urlWithAccountId = relativeUrl + (relativeUrl.includes("?") ? "&" : "?") + `shop=${encodeURIComponent(this.config.shop)}`;
472
415
  const cacheKey = urlWithAccountId;
@@ -1167,7 +1110,7 @@ var StateManager = class {
1167
1110
  if (options.debug) {
1168
1111
  this.middleware.push({
1169
1112
  name: "debug",
1170
- afterUpdate: (state, prevState) => {
1113
+ afterUpdate: (_state, _prevState) => {
1171
1114
  }
1172
1115
  });
1173
1116
  }
@@ -1289,15 +1232,6 @@ var StateManager = class {
1289
1232
  hasStateChanged(prev, next) {
1290
1233
  return JSON.stringify(prev) !== JSON.stringify(next);
1291
1234
  }
1292
- getStateDiff(prev, next) {
1293
- const diff = {};
1294
- for (const key in next) {
1295
- if (prev[key] !== next[key]) {
1296
- diff[key] = next[key];
1297
- }
1298
- }
1299
- return diff;
1300
- }
1301
1235
  persistState() {
1302
1236
  if (this.options.persist) {
1303
1237
  const storage = this.options.persist.storage || localStorage;
@@ -1598,7 +1532,7 @@ function handleOptionChange(optionKey, newValue, currentSelection, attributes) {
1598
1532
  );
1599
1533
  return clearedSelection;
1600
1534
  }
1601
- function clearDependentSelections(changedKey, selection, attributes) {
1535
+ function clearDependentSelections(_changedKey, selection, _attributes) {
1602
1536
  return selection;
1603
1537
  }
1604
1538
  function validateRequiredOptions(selection, attributes) {
@@ -3200,7 +3134,7 @@ var ContextInjector = class {
3200
3134
  setContext(key) {
3201
3135
  return { key, provider };
3202
3136
  },
3203
- getContext(key) {
3137
+ getContext(_key) {
3204
3138
  return provider;
3205
3139
  }
3206
3140
  };
@@ -3258,7 +3192,7 @@ function withContext(Base) {
3258
3192
  onContextError(error) {
3259
3193
  console.error("Context error:", error);
3260
3194
  }
3261
- onContextLoading(loading) {
3195
+ onContextLoading(_loading) {
3262
3196
  }
3263
3197
  findProvider() {
3264
3198
  return void 0;
@@ -4359,7 +4293,7 @@ var ComponentFactory = class {
4359
4293
  * Create a React component
4360
4294
  */
4361
4295
  static forReact(definition, React) {
4362
- const { metadata, descriptor } = definition;
4296
+ const { metadata } = definition;
4363
4297
  const Component = (props) => {
4364
4298
  return React.createElement("div", props);
4365
4299
  };
@@ -4370,12 +4304,12 @@ var ComponentFactory = class {
4370
4304
  * Create a Vue component
4371
4305
  */
4372
4306
  static forVue(definition) {
4373
- const { metadata, descriptor } = definition;
4307
+ const { metadata } = definition;
4374
4308
  return {
4375
4309
  name: metadata.name,
4376
4310
  props: metadata.props,
4377
4311
  emits: metadata.events?.map((e) => e.name),
4378
- setup(props, context) {
4312
+ setup(_props, _context) {
4379
4313
  return () => null;
4380
4314
  }
4381
4315
  };
@@ -4393,7 +4327,7 @@ var ComponentFactory = class {
4393
4327
  * Create a Web Component
4394
4328
  */
4395
4329
  static forWebComponent(definition, LitElement) {
4396
- const { metadata, descriptor } = definition;
4330
+ const { metadata } = definition;
4397
4331
  class Component extends LitElement {
4398
4332
  static properties = metadata.props;
4399
4333
  render() {
@@ -4542,7 +4476,7 @@ var LitAdapter = class {
4542
4476
  /**
4543
4477
  * Render a component
4544
4478
  */
4545
- render(component, props) {
4479
+ render(component, _props) {
4546
4480
  return component.render(this);
4547
4481
  }
4548
4482
  /**
@@ -4563,10 +4497,10 @@ var LitAdapter = class {
4563
4497
  Promise.resolve().then(callback);
4564
4498
  }
4565
4499
  },
4566
- computed: (deps, compute) => {
4500
+ computed: (_deps, compute) => {
4567
4501
  return compute();
4568
4502
  },
4569
- memo: (value, deps) => {
4503
+ memo: (value, _deps) => {
4570
4504
  return value;
4571
4505
  }
4572
4506
  };
@@ -4578,7 +4512,7 @@ var LitAdapter = class {
4578
4512
  this.element = element;
4579
4513
  }
4580
4514
  };
4581
- function createLitComponent(descriptor, LitElement, html) {
4515
+ function createLitComponent(descriptor, LitElement, _html) {
4582
4516
  return class extends LitElement {
4583
4517
  adapter = new LitAdapter(this);
4584
4518
  connectedCallback() {
@@ -4714,7 +4648,7 @@ var VueAdapter = class {
4714
4648
  * Get Vue-specific utilities
4715
4649
  */
4716
4650
  getUtilities() {
4717
- const { nextTick, computed, watchEffect } = this.vue;
4651
+ const { nextTick, computed } = this.vue;
4718
4652
  return {
4719
4653
  batchUpdates: (callback) => {
4720
4654
  callback();
@@ -4722,17 +4656,17 @@ var VueAdapter = class {
4722
4656
  nextTick: (callback) => {
4723
4657
  nextTick(callback);
4724
4658
  },
4725
- computed: (deps, compute) => {
4659
+ computed: (_deps, compute) => {
4726
4660
  return computed(compute).value;
4727
4661
  },
4728
- memo: (value, deps) => {
4662
+ memo: (value, _deps) => {
4729
4663
  return value;
4730
4664
  }
4731
4665
  };
4732
4666
  }
4733
4667
  };
4734
4668
  function createVueComponent(descriptor, vue) {
4735
- const { defineComponent: defineComponent2, h } = vue;
4669
+ const { defineComponent: defineComponent2 } = vue;
4736
4670
  return defineComponent2({
4737
4671
  name: descriptor.name,
4738
4672
  props: descriptor.props || {},
@@ -4754,11 +4688,8 @@ var SvelteAdapter = class {
4754
4688
  name = "svelte";
4755
4689
  svelte;
4756
4690
  // Svelte imports
4757
- component;
4758
- // Component instance
4759
- constructor(svelte, component) {
4691
+ constructor(svelte, _component) {
4760
4692
  this.svelte = svelte;
4761
- this.component = component;
4762
4693
  }
4763
4694
  /**
4764
4695
  * Create a stateful value using Svelte stores
@@ -4849,7 +4780,7 @@ var SvelteAdapter = class {
4849
4780
  /**
4850
4781
  * Render a component
4851
4782
  */
4852
- render(component, props) {
4783
+ render(component, _props) {
4853
4784
  return component.render(this);
4854
4785
  }
4855
4786
  /**
@@ -4869,7 +4800,7 @@ var SvelteAdapter = class {
4869
4800
  const derivedStore = derived(deps, compute);
4870
4801
  return get(derivedStore);
4871
4802
  },
4872
- memo: (value, deps) => {
4803
+ memo: (value, _deps) => {
4873
4804
  return value;
4874
4805
  }
4875
4806
  };
@@ -4917,7 +4848,6 @@ var RealtimeMockupService = class {
4917
4848
  logs = [];
4918
4849
  lastError = null;
4919
4850
  callbacks = {};
4920
- lastBlobSentAt = 0;
4921
4851
  // Per-request send timestamps keyed by requestId, for client-observed
4922
4852
  // round-trip timing in the mockup_rendered log. Pruned to a small cap so an
4923
4853
  // in-flight burst can't grow it unbounded.
@@ -5447,7 +5377,6 @@ var RealtimeMockupService = class {
5447
5377
  });
5448
5378
  this.ws.send(message);
5449
5379
  this.recordRequestSent(requestId);
5450
- this.lastBlobSentAt = Date.now();
5451
5380
  console.log(`[WS] canvas_state(ref) SENT: placement="${placement}" v${this.lastSentVersion} req=${requestId} stateId=${stateId} at ${Date.now()}`);
5452
5381
  this.addLog(`Sent canvas stateId "${stateId}" for "${placement}" (v${this.lastSentVersion}, req ${requestId})`, "sent");
5453
5382
  this.callbacks.onBlobSent?.(placement);
@@ -5485,7 +5414,6 @@ var RealtimeMockupService = class {
5485
5414
  this.ws.send(message);
5486
5415
  this.recordRequestSent(requestId);
5487
5416
  this.lastSentStateJson[placement] = stateJson;
5488
- this.lastBlobSentAt = Date.now();
5489
5417
  console.log(`[WS] canvas_state SENT: placement="${placement}" v${this.lastSentVersion} req=${requestId} (${(message.length / 1024).toFixed(1)}KB) at ${Date.now()}`);
5490
5418
  this.addLog(`Sent canvas state for "${placement}" (${(message.length / 1024).toFixed(1)}KB, v${this.lastSentVersion}, req ${requestId})`, "sent");
5491
5419
  this.callbacks.onBlobSent?.(placement);
@@ -5515,7 +5443,6 @@ ${versionToSend}
5515
5443
  combined.set(imageBytes, headerBytes.length);
5516
5444
  }
5517
5445
  this.ws.send(combined.buffer);
5518
- this.lastBlobSentAt = Date.now();
5519
5446
  this.addLog(`Sent canvas blob for placement "${placement}" (${imageBytes.length} bytes, v${versionToSend})`, "sent");
5520
5447
  if (notifyCallback) {
5521
5448
  this.callbacks.onBlobSent?.(placement);
@@ -6113,82 +6040,6 @@ async function createDesignState(input) {
6113
6040
  return { stateId: ds.id, stateUrl: ds.stateUrl ?? "", previewUrl: ds.previewUrl ?? "" };
6114
6041
  }
6115
6042
 
6116
- // src/upload/grant.ts
6117
- var DEFAULT_UPLOAD_BASE = "https://api.snowcone.app";
6118
- async function mintUploadGrant(opts) {
6119
- const f = opts.fetch ?? globalThis.fetch;
6120
- const headers = { "Content-Type": "application/json" };
6121
- if (opts.apiKey) headers.Authorization = `Bearer ${opts.apiKey}`;
6122
- const res = await f(`${opts.base ?? DEFAULT_UPLOAD_BASE}/uploads/grant`, {
6123
- method: "POST",
6124
- headers,
6125
- body: JSON.stringify({ shop: opts.shop })
6126
- });
6127
- if (!res.ok) {
6128
- const detail = await res.text().catch(() => "");
6129
- throw new Error(`upload grant failed: ${res.status}${detail ? ` ${detail}` : ""}`);
6130
- }
6131
- return await res.json();
6132
- }
6133
- async function fetchUploadGrant(grantUrl, shop, fetchImpl) {
6134
- const f = fetchImpl ?? globalThis.fetch;
6135
- const res = await f(grantUrl, {
6136
- method: "POST",
6137
- headers: { "Content-Type": "application/json" },
6138
- body: JSON.stringify({ shop })
6139
- });
6140
- if (!res.ok) throw new Error(`upload grant failed: ${res.status}`);
6141
- return await res.json();
6142
- }
6143
- async function toImageDataUrl(image) {
6144
- if (typeof image === "string") {
6145
- if (/^data:image\/\w+;base64,/.test(image)) return image;
6146
- throw new Error(
6147
- "uploadAsset: a string image must be a data:image/\u2026;base64 URL (pass a Blob/File otherwise)"
6148
- );
6149
- }
6150
- const bytes = new Uint8Array(await image.arrayBuffer());
6151
- const type = image.type?.startsWith("image/") ? image.type : "image/png";
6152
- const B = globalThis.Buffer;
6153
- let base64;
6154
- if (B) {
6155
- base64 = B.from(bytes).toString("base64");
6156
- } else {
6157
- let bin = "";
6158
- const CHUNK = 32768;
6159
- for (let i = 0; i < bytes.length; i += CHUNK) {
6160
- bin += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
6161
- }
6162
- base64 = btoa(bin);
6163
- }
6164
- return `data:${type};base64,${base64}`;
6165
- }
6166
- async function uploadAsset(image, opts) {
6167
- const f = opts.fetch ?? globalThis.fetch;
6168
- const base = opts.base ?? DEFAULT_UPLOAD_BASE;
6169
- const base64Image = await toImageDataUrl(image);
6170
- let token;
6171
- if (opts.grant) {
6172
- token = typeof opts.grant === "string" ? opts.grant : opts.grant.token;
6173
- } else {
6174
- if (!opts.shop) {
6175
- throw new Error("uploadAsset: `shop` is required unless a `grant` is given");
6176
- }
6177
- const grant = opts.grantUrl ? await fetchUploadGrant(opts.grantUrl, opts.shop, f) : await mintUploadGrant({ apiKey: opts.apiKey, shop: opts.shop, base, fetch: f });
6178
- token = grant.token;
6179
- }
6180
- const res = await f(`${base}/uploads/grant/base64`, {
6181
- method: "POST",
6182
- headers: { "Content-Type": "application/json" },
6183
- body: JSON.stringify({ token, base64Image })
6184
- });
6185
- if (!res.ok) {
6186
- const detail = await res.text().catch(() => "");
6187
- throw new Error(`upload failed: ${res.status}${detail ? ` ${detail}` : ""}`);
6188
- }
6189
- return await res.json();
6190
- }
6191
-
6192
6043
  // src/index.ts
6193
6044
  function getFetcher(config) {
6194
6045
  return config?.fetcher || globalThis.fetch.bind(globalThis);
@@ -6285,7 +6136,6 @@ function createClient(config) {
6285
6136
  DEFAULT_GRANT_BASE,
6286
6137
  DEFAULT_MOCKUP_BASE,
6287
6138
  DEFAULT_PLACEMENT_DIMENSIONS,
6288
- DEFAULT_UPLOAD_BASE,
6289
6139
  Elements,
6290
6140
  ErrorManager,
6291
6141
  EventDelegator,
@@ -6347,7 +6197,6 @@ function createClient(config) {
6347
6197
  describeProductTitle,
6348
6198
  extractProductId,
6349
6199
  fetchRealtimeGrant,
6350
- fetchUploadGrant,
6351
6200
  filterImagePlacements,
6352
6201
  findBestCombination,
6353
6202
  findClosestSnapPoint,
@@ -6373,7 +6222,6 @@ function createClient(config) {
6373
6222
  isValidTileCount,
6374
6223
  listProducts,
6375
6224
  mintRealtimeGrant,
6376
- mintUploadGrant,
6377
6225
  mockupUrl,
6378
6226
  normalizeChoice,
6379
6227
  prepareOptionRenderData,
@@ -6385,7 +6233,6 @@ function createClient(config) {
6385
6233
  simulateCartOperation,
6386
6234
  toCombinations,
6387
6235
  toOptionAttributes,
6388
- uploadAsset,
6389
6236
  useVueAdapter,
6390
6237
  validateAlignment,
6391
6238
  validateDesignElement,
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createDevFetcher } from './dev-fetcher.cjs';
2
2
  import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-url';
3
- import { O as OptionAttribute, a as OptionSelection, C as Combination, F as FrameworkAdapter, b as ComponentProps, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities, P as PlacementSettings, M as MockupResult, R as RealtimeMockupService } from './websocket-X4tcUm78.cjs';
4
- export { A as AdapterRegistry, h as ProductComponentContext, i as RealtimeMockupCallbacks, j as RealtimeMockupState, k as RenderResult, W as WebSocketConfig, l as WebSocketMessage, m as adapterRegistry, n as computeDisabledChoices, o as createComponent, p as defineComponent, q as deriveDefaultSelection, r as findBestCombination, s as getPricePreview, t as isOptionAvailable, u as resolveBestCombination } from './websocket-X4tcUm78.cjs';
3
+ import { O as OptionAttribute, a as OptionSelection, C as Combination, F as FrameworkAdapter, b as ComponentProps, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities, P as PlacementSettings, M as MockupResult, R as RealtimeMockupService } from './websocket-Bfc3nsyG.cjs';
4
+ export { A as AdapterRegistry, h as ProductComponentContext, i as RealtimeMockupCallbacks, j as RealtimeMockupState, k as RenderResult, W as WebSocketConfig, l as WebSocketMessage, m as adapterRegistry, n as computeDisabledChoices, o as createComponent, p as defineComponent, q as deriveDefaultSelection, r as findBestCombination, s as getPricePreview, t as isOptionAvailable, u as resolveBestCombination } from './websocket-Bfc3nsyG.cjs';
5
5
 
6
6
  interface CatalogProduct {
7
7
  id: string;
@@ -396,7 +396,6 @@ declare class StateManager<T extends Record<string, any>> {
396
396
  private processUpdateQueue;
397
397
  private notifySubscribers;
398
398
  private hasStateChanged;
399
- private getStateDiff;
400
399
  private persistState;
401
400
  private loadPersistedState;
402
401
  }
@@ -1674,7 +1673,7 @@ declare function withContext<T extends new (...args: any[]) => any>(Base: T): {
1674
1673
  disconnectedCallback(): void;
1675
1674
  onContextUpdate(context: ProductContext): void;
1676
1675
  onContextError(error: any): void;
1677
- onContextLoading(loading: boolean): void;
1676
+ onContextLoading(_loading: boolean): void;
1678
1677
  findProvider(): UniversalContextProvider | undefined;
1679
1678
  };
1680
1679
  } & T;
@@ -2441,7 +2440,7 @@ declare class LitAdapter implements FrameworkAdapter<ComponentProps> {
2441
2440
  /**
2442
2441
  * Render a component
2443
2442
  */
2444
- render(component: ComponentDescriptor, props: ComponentProps): any;
2443
+ render(component: ComponentDescriptor, _props: ComponentProps): any;
2445
2444
  /**
2446
2445
  * Get Lit-specific utilities
2447
2446
  */
@@ -2454,7 +2453,7 @@ declare class LitAdapter implements FrameworkAdapter<ComponentProps> {
2454
2453
  /**
2455
2454
  * Create a Lit component from a descriptor
2456
2455
  */
2457
- declare function createLitComponent(descriptor: ComponentDescriptor, LitElement: any, html: any): any;
2456
+ declare function createLitComponent(descriptor: ComponentDescriptor, LitElement: any, _html: any): any;
2458
2457
 
2459
2458
  /**
2460
2459
  * Vue 3 framework adapter implementation
@@ -2518,8 +2517,7 @@ declare function useFrameworkAdapter(vue: any): VueAdapter;
2518
2517
  declare class SvelteAdapter implements FrameworkAdapter<ComponentProps> {
2519
2518
  name: "svelte";
2520
2519
  private svelte;
2521
- private component;
2522
- constructor(svelte: any, component?: any);
2520
+ constructor(svelte: any, _component?: any);
2523
2521
  /**
2524
2522
  * Create a stateful value using Svelte stores
2525
2523
  */
@@ -2545,7 +2543,7 @@ declare class SvelteAdapter implements FrameworkAdapter<ComponentProps> {
2545
2543
  /**
2546
2544
  * Render a component
2547
2545
  */
2548
- render(component: ComponentDescriptor, props: ComponentProps): any;
2546
+ render(component: ComponentDescriptor, _props: ComponentProps): any;
2549
2547
  /**
2550
2548
  * Get Svelte-specific utilities
2551
2549
  */
@@ -3061,106 +3059,6 @@ interface CreatedDesignState {
3061
3059
  */
3062
3060
  declare function createDesignState(input: CreateDesignStateInput): Promise<CreatedDesignState>;
3063
3061
 
3064
- /**
3065
- * Upload grant helpers — the realtime grant pattern (ADR-0079), extended to
3066
- * asset uploads so the zero-backend story survives the first user-supplied
3067
- * image. A static page can take a shopper's logo, upload it, and render it on
3068
- * merchandise without any proxy server.
3069
- *
3070
- * A short-lived (5 min) grant token authorizes uploads into the shop's own
3071
- * storage origin (`{shopId}.storage.snowcone.app`) — which is inside the
3072
- * shop's asset-origin allowlist, so the returned URL drops straight into
3073
- * `getMockupUrl` with zero further config. Three ways to get one, mirroring
3074
- * the realtime grant exactly:
3075
- *
3076
- * - {@link mintUploadGrant} — SERVER-SIDE with a secret API key (sk_), or
3077
- * keyless with just the publishable shop id.
3078
- * - {@link fetchUploadGrant} — BROWSER, from your own proxy endpoint.
3079
- * - {@link uploadAsset} — the one-call helper: resolves a grant however you
3080
- * provide it, uploads the image, returns the hosted URL.
3081
- */
3082
- /** A short-lived upload grant. */
3083
- interface UploadGrant {
3084
- /** Opaque token for `POST /uploads/grant/base64`. */
3085
- token: string;
3086
- /** Expiry, epoch seconds. Mint a fresh grant after this. */
3087
- expiresAt: number;
3088
- }
3089
- /** Default backend base URL hosting `POST /uploads/grant`. */
3090
- declare const DEFAULT_UPLOAD_BASE = "https://api.snowcone.app";
3091
- /**
3092
- * Mint an upload grant. Mirrors `mintRealtimeGrant`:
3093
- *
3094
- * Omit `apiKey` (or pass `undefined`/`null`/`''`) for the **keyless
3095
- * publishable path** — the grant is authorized by the publishable `shop` id
3096
- * alone (shops on the L3 signed-URLs rung must use a key or a signed grant
3097
- * request instead). Pass a secret API key (sk_) with the `uploads:write`
3098
- * scope to mint server-side; the key's organization must own the shop.
3099
- *
3100
- * @example
3101
- * // keyless, straight from the browser — quick trials & sandbox shops:
3102
- * const grant = await mintUploadGrant({ shop });
3103
- *
3104
- * @example
3105
- * // your backend route: POST /api/upload/grant
3106
- * const grant = await mintUploadGrant({ apiKey: process.env.SNOWCONE_API_KEY!, shop });
3107
- * return Response.json(grant);
3108
- */
3109
- declare function mintUploadGrant(opts: {
3110
- /**
3111
- * Secret API key (sk_) with the `uploads:write` scope. Omit (or pass
3112
- * `undefined`/`null`/`''`) for the keyless publishable path.
3113
- */
3114
- apiKey?: string | null;
3115
- /** Target shop id (= shop.id). Uploads land in this shop's storage origin. */
3116
- shop: string;
3117
- /** Backend base URL. Defaults to {@link DEFAULT_UPLOAD_BASE}. */
3118
- base?: string;
3119
- /** Override fetch (e.g. in tests / non-global-fetch runtimes). */
3120
- fetch?: typeof fetch;
3121
- }): Promise<UploadGrant>;
3122
- /**
3123
- * BROWSER: fetch an upload grant from your own proxy endpoint, which calls
3124
- * {@link mintUploadGrant} server-side (when you want the sk_ path without
3125
- * shipping the key). The proxy receives `POST { shop }` and returns
3126
- * `{ token, expiresAt }`.
3127
- */
3128
- declare function fetchUploadGrant(grantUrl: string, shop: string, fetchImpl?: typeof fetch): Promise<UploadGrant>;
3129
- /**
3130
- * Upload an image and get back its hosted URL — ready to pass as `asset` to
3131
- * `getMockupUrl` / `getBuyUrl` (it lands on the shop's own storage origin, so
3132
- * it's already on the asset-origin allowlist).
3133
- *
3134
- * Provide auth in whichever shape fits:
3135
- * - `{ shop }` alone — keyless publishable path (mints the grant for you),
3136
- * - `{ shop, grantUrl }` — exchange via your own proxy endpoint,
3137
- * - `{ shop, apiKey }` — server-side with an sk_ key,
3138
- * - `{ grant }` — a grant you already hold (token reusable until it expires).
3139
- *
3140
- * @example
3141
- * // a static page, no backend anywhere:
3142
- * const { url } = await uploadAsset(fileInput.files[0], { shop });
3143
- * img.src = getMockupUrl("BEEB77", { shop, asset: url });
3144
- */
3145
- declare function uploadAsset(
3146
- /** A `Blob`/`File`, or a `data:image/…;base64,` URL. */
3147
- image: Blob | string, opts: {
3148
- /** Target shop id. Required unless a pre-fetched `grant` is given. */
3149
- shop?: string;
3150
- /** A grant you already hold (or its raw token). Skips minting. */
3151
- grant?: UploadGrant | string;
3152
- /** Your own proxy endpoint that returns a grant (see {@link fetchUploadGrant}). */
3153
- grantUrl?: string;
3154
- /** Secret API key (sk_, scope `uploads:write`) for server-side minting. */
3155
- apiKey?: string | null;
3156
- /** Backend base URL. Defaults to {@link DEFAULT_UPLOAD_BASE}. */
3157
- base?: string;
3158
- /** Override fetch. */
3159
- fetch?: typeof fetch;
3160
- }): Promise<{
3161
- url: string;
3162
- }>;
3163
-
3164
3062
  interface ProductPlacement {
3165
3063
  label: string;
3166
3064
  x: number;
@@ -3215,4 +3113,4 @@ declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Prom
3215
3113
  */
3216
3114
  declare function createClient(config: SdkConfig): SnowconeClient;
3217
3115
 
3218
- export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogListResponse, type CatalogProduct, 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, DEFAULT_UPLOAD_BASE, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, 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, 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 SignedUrlResponse, type SnowconeClient, StandardComponents, StandardEvents, StateManager, type StateManagerOptions, type StateMiddleware, type StateSelector, type StateSubscriber, type StateUpdater, Styles, SvelteAdapter, SwatchUtils, type TagName, TemplateBuilder, type TemplateNode, type TemplateNodeType, type TemplateRenderer, type TextDescriptor, type TileCount, UniversalContextProvider, type UploadGrant, 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, fetchRealtimeGrant, fetchUploadGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mintUploadGrant, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupId, resolveVariantId, retryOperation, simulateCartOperation, toCombinations, toOptionAttributes, uploadAsset, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
3116
+ export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogListResponse, type CatalogProduct, 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 Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, 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, 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 SignedUrlResponse, type SnowconeClient, StandardComponents, StandardEvents, StateManager, type StateManagerOptions, type StateMiddleware, type StateSelector, type StateSubscriber, type StateUpdater, Styles, SvelteAdapter, SwatchUtils, type TagName, TemplateBuilder, type TemplateNode, type TemplateNodeType, type TemplateRenderer, type TextDescriptor, type TileCount, UniversalContextProvider, type UserSelection, type ValidationError, type ValidationResult, VueAdapter, 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, fetchRealtimeGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupId, resolveVariantId, retryOperation, 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,7 +1,7 @@
1
1
  export { createDevFetcher } from './dev-fetcher.js';
2
2
  import { PublicDesign, PublicFill, PublicOptions } from '@snowcone-app/mockup-url';
3
- import { O as OptionAttribute, a as OptionSelection, C as Combination, F as FrameworkAdapter, b as ComponentProps, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities, P as PlacementSettings, M as MockupResult, R as RealtimeMockupService } from './websocket-X4tcUm78.js';
4
- export { A as AdapterRegistry, h as ProductComponentContext, i as RealtimeMockupCallbacks, j as RealtimeMockupState, k as RenderResult, W as WebSocketConfig, l as WebSocketMessage, m as adapterRegistry, n as computeDisabledChoices, o as createComponent, p as defineComponent, q as deriveDefaultSelection, r as findBestCombination, s as getPricePreview, t as isOptionAvailable, u as resolveBestCombination } from './websocket-X4tcUm78.js';
3
+ import { O as OptionAttribute, a as OptionSelection, C as Combination, F as FrameworkAdapter, b as ComponentProps, c as ComponentDescriptor, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, g as FrameworkUtilities, P as PlacementSettings, M as MockupResult, R as RealtimeMockupService } from './websocket-Bfc3nsyG.js';
4
+ export { A as AdapterRegistry, h as ProductComponentContext, i as RealtimeMockupCallbacks, j as RealtimeMockupState, k as RenderResult, W as WebSocketConfig, l as WebSocketMessage, m as adapterRegistry, n as computeDisabledChoices, o as createComponent, p as defineComponent, q as deriveDefaultSelection, r as findBestCombination, s as getPricePreview, t as isOptionAvailable, u as resolveBestCombination } from './websocket-Bfc3nsyG.js';
5
5
 
6
6
  interface CatalogProduct {
7
7
  id: string;
@@ -396,7 +396,6 @@ declare class StateManager<T extends Record<string, any>> {
396
396
  private processUpdateQueue;
397
397
  private notifySubscribers;
398
398
  private hasStateChanged;
399
- private getStateDiff;
400
399
  private persistState;
401
400
  private loadPersistedState;
402
401
  }
@@ -1674,7 +1673,7 @@ declare function withContext<T extends new (...args: any[]) => any>(Base: T): {
1674
1673
  disconnectedCallback(): void;
1675
1674
  onContextUpdate(context: ProductContext): void;
1676
1675
  onContextError(error: any): void;
1677
- onContextLoading(loading: boolean): void;
1676
+ onContextLoading(_loading: boolean): void;
1678
1677
  findProvider(): UniversalContextProvider | undefined;
1679
1678
  };
1680
1679
  } & T;
@@ -2441,7 +2440,7 @@ declare class LitAdapter implements FrameworkAdapter<ComponentProps> {
2441
2440
  /**
2442
2441
  * Render a component
2443
2442
  */
2444
- render(component: ComponentDescriptor, props: ComponentProps): any;
2443
+ render(component: ComponentDescriptor, _props: ComponentProps): any;
2445
2444
  /**
2446
2445
  * Get Lit-specific utilities
2447
2446
  */
@@ -2454,7 +2453,7 @@ declare class LitAdapter implements FrameworkAdapter<ComponentProps> {
2454
2453
  /**
2455
2454
  * Create a Lit component from a descriptor
2456
2455
  */
2457
- declare function createLitComponent(descriptor: ComponentDescriptor, LitElement: any, html: any): any;
2456
+ declare function createLitComponent(descriptor: ComponentDescriptor, LitElement: any, _html: any): any;
2458
2457
 
2459
2458
  /**
2460
2459
  * Vue 3 framework adapter implementation
@@ -2518,8 +2517,7 @@ declare function useFrameworkAdapter(vue: any): VueAdapter;
2518
2517
  declare class SvelteAdapter implements FrameworkAdapter<ComponentProps> {
2519
2518
  name: "svelte";
2520
2519
  private svelte;
2521
- private component;
2522
- constructor(svelte: any, component?: any);
2520
+ constructor(svelte: any, _component?: any);
2523
2521
  /**
2524
2522
  * Create a stateful value using Svelte stores
2525
2523
  */
@@ -2545,7 +2543,7 @@ declare class SvelteAdapter implements FrameworkAdapter<ComponentProps> {
2545
2543
  /**
2546
2544
  * Render a component
2547
2545
  */
2548
- render(component: ComponentDescriptor, props: ComponentProps): any;
2546
+ render(component: ComponentDescriptor, _props: ComponentProps): any;
2549
2547
  /**
2550
2548
  * Get Svelte-specific utilities
2551
2549
  */
@@ -3061,106 +3059,6 @@ interface CreatedDesignState {
3061
3059
  */
3062
3060
  declare function createDesignState(input: CreateDesignStateInput): Promise<CreatedDesignState>;
3063
3061
 
3064
- /**
3065
- * Upload grant helpers — the realtime grant pattern (ADR-0079), extended to
3066
- * asset uploads so the zero-backend story survives the first user-supplied
3067
- * image. A static page can take a shopper's logo, upload it, and render it on
3068
- * merchandise without any proxy server.
3069
- *
3070
- * A short-lived (5 min) grant token authorizes uploads into the shop's own
3071
- * storage origin (`{shopId}.storage.snowcone.app`) — which is inside the
3072
- * shop's asset-origin allowlist, so the returned URL drops straight into
3073
- * `getMockupUrl` with zero further config. Three ways to get one, mirroring
3074
- * the realtime grant exactly:
3075
- *
3076
- * - {@link mintUploadGrant} — SERVER-SIDE with a secret API key (sk_), or
3077
- * keyless with just the publishable shop id.
3078
- * - {@link fetchUploadGrant} — BROWSER, from your own proxy endpoint.
3079
- * - {@link uploadAsset} — the one-call helper: resolves a grant however you
3080
- * provide it, uploads the image, returns the hosted URL.
3081
- */
3082
- /** A short-lived upload grant. */
3083
- interface UploadGrant {
3084
- /** Opaque token for `POST /uploads/grant/base64`. */
3085
- token: string;
3086
- /** Expiry, epoch seconds. Mint a fresh grant after this. */
3087
- expiresAt: number;
3088
- }
3089
- /** Default backend base URL hosting `POST /uploads/grant`. */
3090
- declare const DEFAULT_UPLOAD_BASE = "https://api.snowcone.app";
3091
- /**
3092
- * Mint an upload grant. Mirrors `mintRealtimeGrant`:
3093
- *
3094
- * Omit `apiKey` (or pass `undefined`/`null`/`''`) for the **keyless
3095
- * publishable path** — the grant is authorized by the publishable `shop` id
3096
- * alone (shops on the L3 signed-URLs rung must use a key or a signed grant
3097
- * request instead). Pass a secret API key (sk_) with the `uploads:write`
3098
- * scope to mint server-side; the key's organization must own the shop.
3099
- *
3100
- * @example
3101
- * // keyless, straight from the browser — quick trials & sandbox shops:
3102
- * const grant = await mintUploadGrant({ shop });
3103
- *
3104
- * @example
3105
- * // your backend route: POST /api/upload/grant
3106
- * const grant = await mintUploadGrant({ apiKey: process.env.SNOWCONE_API_KEY!, shop });
3107
- * return Response.json(grant);
3108
- */
3109
- declare function mintUploadGrant(opts: {
3110
- /**
3111
- * Secret API key (sk_) with the `uploads:write` scope. Omit (or pass
3112
- * `undefined`/`null`/`''`) for the keyless publishable path.
3113
- */
3114
- apiKey?: string | null;
3115
- /** Target shop id (= shop.id). Uploads land in this shop's storage origin. */
3116
- shop: string;
3117
- /** Backend base URL. Defaults to {@link DEFAULT_UPLOAD_BASE}. */
3118
- base?: string;
3119
- /** Override fetch (e.g. in tests / non-global-fetch runtimes). */
3120
- fetch?: typeof fetch;
3121
- }): Promise<UploadGrant>;
3122
- /**
3123
- * BROWSER: fetch an upload grant from your own proxy endpoint, which calls
3124
- * {@link mintUploadGrant} server-side (when you want the sk_ path without
3125
- * shipping the key). The proxy receives `POST { shop }` and returns
3126
- * `{ token, expiresAt }`.
3127
- */
3128
- declare function fetchUploadGrant(grantUrl: string, shop: string, fetchImpl?: typeof fetch): Promise<UploadGrant>;
3129
- /**
3130
- * Upload an image and get back its hosted URL — ready to pass as `asset` to
3131
- * `getMockupUrl` / `getBuyUrl` (it lands on the shop's own storage origin, so
3132
- * it's already on the asset-origin allowlist).
3133
- *
3134
- * Provide auth in whichever shape fits:
3135
- * - `{ shop }` alone — keyless publishable path (mints the grant for you),
3136
- * - `{ shop, grantUrl }` — exchange via your own proxy endpoint,
3137
- * - `{ shop, apiKey }` — server-side with an sk_ key,
3138
- * - `{ grant }` — a grant you already hold (token reusable until it expires).
3139
- *
3140
- * @example
3141
- * // a static page, no backend anywhere:
3142
- * const { url } = await uploadAsset(fileInput.files[0], { shop });
3143
- * img.src = getMockupUrl("BEEB77", { shop, asset: url });
3144
- */
3145
- declare function uploadAsset(
3146
- /** A `Blob`/`File`, or a `data:image/…;base64,` URL. */
3147
- image: Blob | string, opts: {
3148
- /** Target shop id. Required unless a pre-fetched `grant` is given. */
3149
- shop?: string;
3150
- /** A grant you already hold (or its raw token). Skips minting. */
3151
- grant?: UploadGrant | string;
3152
- /** Your own proxy endpoint that returns a grant (see {@link fetchUploadGrant}). */
3153
- grantUrl?: string;
3154
- /** Secret API key (sk_, scope `uploads:write`) for server-side minting. */
3155
- apiKey?: string | null;
3156
- /** Backend base URL. Defaults to {@link DEFAULT_UPLOAD_BASE}. */
3157
- base?: string;
3158
- /** Override fetch. */
3159
- fetch?: typeof fetch;
3160
- }): Promise<{
3161
- url: string;
3162
- }>;
3163
-
3164
3062
  interface ProductPlacement {
3165
3063
  label: string;
3166
3064
  x: number;
@@ -3215,4 +3113,4 @@ declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Prom
3215
3113
  */
3216
3114
  declare function createClient(config: SdkConfig): SnowconeClient;
3217
3115
 
3218
- export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogListResponse, type CatalogProduct, 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, DEFAULT_UPLOAD_BASE, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, 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, 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 SignedUrlResponse, type SnowconeClient, StandardComponents, StandardEvents, StateManager, type StateManagerOptions, type StateMiddleware, type StateSelector, type StateSubscriber, type StateUpdater, Styles, SvelteAdapter, SwatchUtils, type TagName, TemplateBuilder, type TemplateNode, type TemplateNodeType, type TemplateRenderer, type TextDescriptor, type TileCount, UniversalContextProvider, type UploadGrant, 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, fetchRealtimeGrant, fetchUploadGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mintUploadGrant, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupId, resolveVariantId, retryOperation, simulateCartOperation, toCombinations, toOptionAttributes, uploadAsset, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
3116
+ export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogListResponse, type CatalogProduct, 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 Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type Fill, Focus, FrameworkAdapter, FrameworkUtilities, type GetMockupUrlOptions, type ImageAlignment, type ImageDesignElement, type LifecycleHook, LifecycleManager, type LifecyclePhase, type LifecycleTransition, LitAdapter, type MaskOverride, type MockupGenerationOptions, 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, 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 SignedUrlResponse, type SnowconeClient, StandardComponents, StandardEvents, StateManager, type StateManagerOptions, type StateMiddleware, type StateSelector, type StateSubscriber, type StateUpdater, Styles, SvelteAdapter, SwatchUtils, type TagName, TemplateBuilder, type TemplateNode, type TemplateNodeType, type TemplateRenderer, type TextDescriptor, type TileCount, UniversalContextProvider, type UserSelection, type ValidationError, type ValidationResult, VueAdapter, 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, fetchRealtimeGrant, filterImagePlacements, findClosestSnapPoint, findVariantForSelection, formatPrice, formatValidationErrors, getBuyUrl, getDefaultVariantId, getEffectiveAlignment, getIncompleteSelectionMessage, getMissingSelections, getMockupUrl, getOptionRenderType, getProduct, getSelectionDisplayText, getSnapPoints, getVariant, handleOptionChange, isSelectionComplete, isValidAlignment, isValidTileCount, listProducts, mintRealtimeGrant, mockupUrl, normalizeChoice, prepareOptionRenderData, registerStandardComponents, resolveMockupId, resolveVariantId, retryOperation, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  REALTIME_WS_URL,
6
6
  RealtimeMockupService
7
- } from "./chunk-LYLIDU6G.js";
7
+ } from "./chunk-QHRQ3VJD.js";
8
8
  import {
9
9
  buildMockupUrl,
10
10
  buildPublicMockupUrl,
@@ -267,59 +267,6 @@ var MockupServiceImpl = class {
267
267
  }
268
268
  return url;
269
269
  }
270
- buildMockupUrl(options) {
271
- const { design, product, effects } = options;
272
- const pathSegments = ["m"];
273
- pathSegments.push(product.productId);
274
- pathSegments.push(product.mockupId);
275
- pathSegments.push(product.variantId);
276
- pathSegments.push(String(product.width));
277
- const designParts = [];
278
- for (const element of design) {
279
- const part = this.encodeDesignElement(element);
280
- designParts.push(part);
281
- }
282
- if (designParts.length > 0) {
283
- pathSegments.push(designParts.join("_"));
284
- } else {
285
- pathSegments.push("");
286
- }
287
- if (effects?.grain) {
288
- pathSegments.push(`g${effects.grain}`);
289
- }
290
- return "/" + pathSegments.join("/");
291
- }
292
- encodeDesignElement(element) {
293
- const parts = [];
294
- if (element.type === "image") {
295
- const encodedUrl = this.encodeImageUrl(element.imageUrl);
296
- parts.push(encodedUrl);
297
- parts.push(element.placement);
298
- parts.push(String(element.width));
299
- parts.push(String(element.height));
300
- parts.push(element.alignment);
301
- if (element.tiles && element.tiles > 1) {
302
- parts.push(`t${element.tiles}`);
303
- }
304
- } else if (element.type === "color") {
305
- const colorCode = element.hex.replace("#", "");
306
- parts.push(colorCode);
307
- parts.push(element.placement);
308
- parts.push(String(element.width));
309
- parts.push(String(element.height));
310
- parts.push(element.alignment);
311
- }
312
- return parts.join(",");
313
- }
314
- encodeImageUrl(url) {
315
- if (typeof window !== "undefined" && window.btoa) {
316
- const base64 = window.btoa(url);
317
- return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
318
- } else {
319
- const base64 = Buffer.from(url).toString("base64");
320
- return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
321
- }
322
- }
323
270
  async getSignedUrl(relativeUrl) {
324
271
  const urlWithAccountId = relativeUrl + (relativeUrl.includes("?") ? "&" : "?") + `shop=${encodeURIComponent(this.config.shop)}`;
325
272
  const cacheKey = urlWithAccountId;
@@ -797,7 +744,7 @@ var StateManager = class {
797
744
  if (options.debug) {
798
745
  this.middleware.push({
799
746
  name: "debug",
800
- afterUpdate: (state, prevState) => {
747
+ afterUpdate: (_state, _prevState) => {
801
748
  }
802
749
  });
803
750
  }
@@ -919,15 +866,6 @@ var StateManager = class {
919
866
  hasStateChanged(prev, next) {
920
867
  return JSON.stringify(prev) !== JSON.stringify(next);
921
868
  }
922
- getStateDiff(prev, next) {
923
- const diff = {};
924
- for (const key in next) {
925
- if (prev[key] !== next[key]) {
926
- diff[key] = next[key];
927
- }
928
- }
929
- return diff;
930
- }
931
869
  persistState() {
932
870
  if (this.options.persist) {
933
871
  const storage = this.options.persist.storage || localStorage;
@@ -1228,7 +1166,7 @@ function handleOptionChange(optionKey, newValue, currentSelection, attributes) {
1228
1166
  );
1229
1167
  return clearedSelection;
1230
1168
  }
1231
- function clearDependentSelections(changedKey, selection, attributes) {
1169
+ function clearDependentSelections(_changedKey, selection, _attributes) {
1232
1170
  return selection;
1233
1171
  }
1234
1172
  function validateRequiredOptions(selection, attributes) {
@@ -2830,7 +2768,7 @@ var ContextInjector = class {
2830
2768
  setContext(key) {
2831
2769
  return { key, provider };
2832
2770
  },
2833
- getContext(key) {
2771
+ getContext(_key) {
2834
2772
  return provider;
2835
2773
  }
2836
2774
  };
@@ -2888,7 +2826,7 @@ function withContext(Base) {
2888
2826
  onContextError(error) {
2889
2827
  console.error("Context error:", error);
2890
2828
  }
2891
- onContextLoading(loading) {
2829
+ onContextLoading(_loading) {
2892
2830
  }
2893
2831
  findProvider() {
2894
2832
  return void 0;
@@ -3989,7 +3927,7 @@ var ComponentFactory = class {
3989
3927
  * Create a React component
3990
3928
  */
3991
3929
  static forReact(definition, React) {
3992
- const { metadata, descriptor } = definition;
3930
+ const { metadata } = definition;
3993
3931
  const Component = (props) => {
3994
3932
  return React.createElement("div", props);
3995
3933
  };
@@ -4000,12 +3938,12 @@ var ComponentFactory = class {
4000
3938
  * Create a Vue component
4001
3939
  */
4002
3940
  static forVue(definition) {
4003
- const { metadata, descriptor } = definition;
3941
+ const { metadata } = definition;
4004
3942
  return {
4005
3943
  name: metadata.name,
4006
3944
  props: metadata.props,
4007
3945
  emits: metadata.events?.map((e) => e.name),
4008
- setup(props, context) {
3946
+ setup(_props, _context) {
4009
3947
  return () => null;
4010
3948
  }
4011
3949
  };
@@ -4023,7 +3961,7 @@ var ComponentFactory = class {
4023
3961
  * Create a Web Component
4024
3962
  */
4025
3963
  static forWebComponent(definition, LitElement) {
4026
- const { metadata, descriptor } = definition;
3964
+ const { metadata } = definition;
4027
3965
  class Component extends LitElement {
4028
3966
  static properties = metadata.props;
4029
3967
  render() {
@@ -4172,7 +4110,7 @@ var LitAdapter = class {
4172
4110
  /**
4173
4111
  * Render a component
4174
4112
  */
4175
- render(component, props) {
4113
+ render(component, _props) {
4176
4114
  return component.render(this);
4177
4115
  }
4178
4116
  /**
@@ -4193,10 +4131,10 @@ var LitAdapter = class {
4193
4131
  Promise.resolve().then(callback);
4194
4132
  }
4195
4133
  },
4196
- computed: (deps, compute) => {
4134
+ computed: (_deps, compute) => {
4197
4135
  return compute();
4198
4136
  },
4199
- memo: (value, deps) => {
4137
+ memo: (value, _deps) => {
4200
4138
  return value;
4201
4139
  }
4202
4140
  };
@@ -4208,7 +4146,7 @@ var LitAdapter = class {
4208
4146
  this.element = element;
4209
4147
  }
4210
4148
  };
4211
- function createLitComponent(descriptor, LitElement, html) {
4149
+ function createLitComponent(descriptor, LitElement, _html) {
4212
4150
  return class extends LitElement {
4213
4151
  adapter = new LitAdapter(this);
4214
4152
  connectedCallback() {
@@ -4344,7 +4282,7 @@ var VueAdapter = class {
4344
4282
  * Get Vue-specific utilities
4345
4283
  */
4346
4284
  getUtilities() {
4347
- const { nextTick, computed, watchEffect } = this.vue;
4285
+ const { nextTick, computed } = this.vue;
4348
4286
  return {
4349
4287
  batchUpdates: (callback) => {
4350
4288
  callback();
@@ -4352,17 +4290,17 @@ var VueAdapter = class {
4352
4290
  nextTick: (callback) => {
4353
4291
  nextTick(callback);
4354
4292
  },
4355
- computed: (deps, compute) => {
4293
+ computed: (_deps, compute) => {
4356
4294
  return computed(compute).value;
4357
4295
  },
4358
- memo: (value, deps) => {
4296
+ memo: (value, _deps) => {
4359
4297
  return value;
4360
4298
  }
4361
4299
  };
4362
4300
  }
4363
4301
  };
4364
4302
  function createVueComponent(descriptor, vue) {
4365
- const { defineComponent: defineComponent2, h } = vue;
4303
+ const { defineComponent: defineComponent2 } = vue;
4366
4304
  return defineComponent2({
4367
4305
  name: descriptor.name,
4368
4306
  props: descriptor.props || {},
@@ -4384,11 +4322,8 @@ var SvelteAdapter = class {
4384
4322
  name = "svelte";
4385
4323
  svelte;
4386
4324
  // Svelte imports
4387
- component;
4388
- // Component instance
4389
- constructor(svelte, component) {
4325
+ constructor(svelte, _component) {
4390
4326
  this.svelte = svelte;
4391
- this.component = component;
4392
4327
  }
4393
4328
  /**
4394
4329
  * Create a stateful value using Svelte stores
@@ -4479,7 +4414,7 @@ var SvelteAdapter = class {
4479
4414
  /**
4480
4415
  * Render a component
4481
4416
  */
4482
- render(component, props) {
4417
+ render(component, _props) {
4483
4418
  return component.render(this);
4484
4419
  }
4485
4420
  /**
@@ -4499,7 +4434,7 @@ var SvelteAdapter = class {
4499
4434
  const derivedStore = derived(deps, compute);
4500
4435
  return get(derivedStore);
4501
4436
  },
4502
- memo: (value, deps) => {
4437
+ memo: (value, _deps) => {
4503
4438
  return value;
4504
4439
  }
4505
4440
  };
@@ -4981,82 +4916,6 @@ async function createDesignState(input) {
4981
4916
  return { stateId: ds.id, stateUrl: ds.stateUrl ?? "", previewUrl: ds.previewUrl ?? "" };
4982
4917
  }
4983
4918
 
4984
- // src/upload/grant.ts
4985
- var DEFAULT_UPLOAD_BASE = "https://api.snowcone.app";
4986
- async function mintUploadGrant(opts) {
4987
- const f = opts.fetch ?? globalThis.fetch;
4988
- const headers = { "Content-Type": "application/json" };
4989
- if (opts.apiKey) headers.Authorization = `Bearer ${opts.apiKey}`;
4990
- const res = await f(`${opts.base ?? DEFAULT_UPLOAD_BASE}/uploads/grant`, {
4991
- method: "POST",
4992
- headers,
4993
- body: JSON.stringify({ shop: opts.shop })
4994
- });
4995
- if (!res.ok) {
4996
- const detail = await res.text().catch(() => "");
4997
- throw new Error(`upload grant failed: ${res.status}${detail ? ` ${detail}` : ""}`);
4998
- }
4999
- return await res.json();
5000
- }
5001
- async function fetchUploadGrant(grantUrl, shop, fetchImpl) {
5002
- const f = fetchImpl ?? globalThis.fetch;
5003
- const res = await f(grantUrl, {
5004
- method: "POST",
5005
- headers: { "Content-Type": "application/json" },
5006
- body: JSON.stringify({ shop })
5007
- });
5008
- if (!res.ok) throw new Error(`upload grant failed: ${res.status}`);
5009
- return await res.json();
5010
- }
5011
- async function toImageDataUrl(image) {
5012
- if (typeof image === "string") {
5013
- if (/^data:image\/\w+;base64,/.test(image)) return image;
5014
- throw new Error(
5015
- "uploadAsset: a string image must be a data:image/\u2026;base64 URL (pass a Blob/File otherwise)"
5016
- );
5017
- }
5018
- const bytes = new Uint8Array(await image.arrayBuffer());
5019
- const type = image.type?.startsWith("image/") ? image.type : "image/png";
5020
- const B = globalThis.Buffer;
5021
- let base64;
5022
- if (B) {
5023
- base64 = B.from(bytes).toString("base64");
5024
- } else {
5025
- let bin = "";
5026
- const CHUNK = 32768;
5027
- for (let i = 0; i < bytes.length; i += CHUNK) {
5028
- bin += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
5029
- }
5030
- base64 = btoa(bin);
5031
- }
5032
- return `data:${type};base64,${base64}`;
5033
- }
5034
- async function uploadAsset(image, opts) {
5035
- const f = opts.fetch ?? globalThis.fetch;
5036
- const base = opts.base ?? DEFAULT_UPLOAD_BASE;
5037
- const base64Image = await toImageDataUrl(image);
5038
- let token;
5039
- if (opts.grant) {
5040
- token = typeof opts.grant === "string" ? opts.grant : opts.grant.token;
5041
- } else {
5042
- if (!opts.shop) {
5043
- throw new Error("uploadAsset: `shop` is required unless a `grant` is given");
5044
- }
5045
- const grant = opts.grantUrl ? await fetchUploadGrant(opts.grantUrl, opts.shop, f) : await mintUploadGrant({ apiKey: opts.apiKey, shop: opts.shop, base, fetch: f });
5046
- token = grant.token;
5047
- }
5048
- const res = await f(`${base}/uploads/grant/base64`, {
5049
- method: "POST",
5050
- headers: { "Content-Type": "application/json" },
5051
- body: JSON.stringify({ token, base64Image })
5052
- });
5053
- if (!res.ok) {
5054
- const detail = await res.text().catch(() => "");
5055
- throw new Error(`upload failed: ${res.status}${detail ? ` ${detail}` : ""}`);
5056
- }
5057
- return await res.json();
5058
- }
5059
-
5060
4919
  // src/index.ts
5061
4920
  function getFetcher(config) {
5062
4921
  return config?.fetcher || globalThis.fetch.bind(globalThis);
@@ -5152,7 +5011,6 @@ export {
5152
5011
  DEFAULT_GRANT_BASE,
5153
5012
  DEFAULT_MOCKUP_BASE,
5154
5013
  DEFAULT_PLACEMENT_DIMENSIONS,
5155
- DEFAULT_UPLOAD_BASE,
5156
5014
  Elements,
5157
5015
  ErrorManager,
5158
5016
  EventDelegator,
@@ -5214,7 +5072,6 @@ export {
5214
5072
  describeProductTitle,
5215
5073
  extractProductId,
5216
5074
  fetchRealtimeGrant,
5217
- fetchUploadGrant,
5218
5075
  filterImagePlacements,
5219
5076
  findBestCombination,
5220
5077
  findClosestSnapPoint,
@@ -5240,7 +5097,6 @@ export {
5240
5097
  isValidTileCount,
5241
5098
  listProducts,
5242
5099
  mintRealtimeGrant,
5243
- mintUploadGrant,
5244
5100
  mockupUrl,
5245
5101
  normalizeChoice,
5246
5102
  prepareOptionRenderData,
@@ -5252,7 +5108,6 @@ export {
5252
5108
  simulateCartOperation,
5253
5109
  toCombinations,
5254
5110
  toOptionAttributes,
5255
- uploadAsset,
5256
5111
  useFrameworkAdapter as useVueAdapter,
5257
5112
  validateAlignment,
5258
5113
  validateDesignElement,
package/dist/react.cjs CHANGED
@@ -58,7 +58,6 @@ var RealtimeMockupService = class {
58
58
  logs = [];
59
59
  lastError = null;
60
60
  callbacks = {};
61
- lastBlobSentAt = 0;
62
61
  // Per-request send timestamps keyed by requestId, for client-observed
63
62
  // round-trip timing in the mockup_rendered log. Pruned to a small cap so an
64
63
  // in-flight burst can't grow it unbounded.
@@ -588,7 +587,6 @@ var RealtimeMockupService = class {
588
587
  });
589
588
  this.ws.send(message);
590
589
  this.recordRequestSent(requestId);
591
- this.lastBlobSentAt = Date.now();
592
590
  console.log(`[WS] canvas_state(ref) SENT: placement="${placement}" v${this.lastSentVersion} req=${requestId} stateId=${stateId} at ${Date.now()}`);
593
591
  this.addLog(`Sent canvas stateId "${stateId}" for "${placement}" (v${this.lastSentVersion}, req ${requestId})`, "sent");
594
592
  this.callbacks.onBlobSent?.(placement);
@@ -626,7 +624,6 @@ var RealtimeMockupService = class {
626
624
  this.ws.send(message);
627
625
  this.recordRequestSent(requestId);
628
626
  this.lastSentStateJson[placement] = stateJson;
629
- this.lastBlobSentAt = Date.now();
630
627
  console.log(`[WS] canvas_state SENT: placement="${placement}" v${this.lastSentVersion} req=${requestId} (${(message.length / 1024).toFixed(1)}KB) at ${Date.now()}`);
631
628
  this.addLog(`Sent canvas state for "${placement}" (${(message.length / 1024).toFixed(1)}KB, v${this.lastSentVersion}, req ${requestId})`, "sent");
632
629
  this.callbacks.onBlobSent?.(placement);
@@ -656,7 +653,6 @@ ${versionToSend}
656
653
  combined.set(imageBytes, headerBytes.length);
657
654
  }
658
655
  this.ws.send(combined.buffer);
659
- this.lastBlobSentAt = Date.now();
660
656
  this.addLog(`Sent canvas blob for placement "${placement}" (${imageBytes.length} bytes, v${versionToSend})`, "sent");
661
657
  if (notifyCallback) {
662
658
  this.callbacks.onBlobSent?.(placement);
package/dist/react.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as MockupResult, W as WebSocketConfig, P as PlacementSettings, F as FrameworkAdapter, b as ComponentProps, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, c as ComponentDescriptor, g as FrameworkUtilities } from './websocket-X4tcUm78.cjs';
1
+ import { M as MockupResult, W as WebSocketConfig, P as PlacementSettings, F as FrameworkAdapter, b as ComponentProps, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, c as ComponentDescriptor, g as FrameworkUtilities } from './websocket-Bfc3nsyG.cjs';
2
2
 
3
3
  interface UseRealtimeMockupOptions {
4
4
  wsUrl?: string;
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as MockupResult, W as WebSocketConfig, P as PlacementSettings, F as FrameworkAdapter, b as ComponentProps, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, c as ComponentDescriptor, g as FrameworkUtilities } from './websocket-X4tcUm78.js';
1
+ import { M as MockupResult, W as WebSocketConfig, P as PlacementSettings, F as FrameworkAdapter, b as ComponentProps, d as ComponentState, e as ComponentContext, f as ComponentLifecycleHooks, E as EventHandler, c as ComponentDescriptor, g as FrameworkUtilities } from './websocket-Bfc3nsyG.js';
2
2
 
3
3
  interface UseRealtimeMockupOptions {
4
4
  wsUrl?: string;
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RealtimeMockupService
3
- } from "./chunk-LYLIDU6G.js";
3
+ } from "./chunk-QHRQ3VJD.js";
4
4
 
5
5
  // src/realtime/react.ts
6
6
  import { useCallback, useEffect, useRef, useState } from "react";
@@ -316,7 +316,6 @@ declare class RealtimeMockupService {
316
316
  private logs;
317
317
  private lastError;
318
318
  private callbacks;
319
- private lastBlobSentAt;
320
319
  private requestSendTimes;
321
320
  private canvasBlobs;
322
321
  private canvasStates;
@@ -316,7 +316,6 @@ declare class RealtimeMockupService {
316
316
  private logs;
317
317
  private lastError;
318
318
  private callbacks;
319
- private lastBlobSentAt;
320
319
  private requestSendTimes;
321
320
  private canvasBlobs;
322
321
  private canvasStates;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowcone-app/sdk",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "Snowcone SDK for product mockups and print-on-demand",
5
5
  "keywords": [
6
6
  "merch",