@snowcone-app/sdk 0.24.3 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +7 -7
- package/dist/{chunk-FQC2FPV7.js → chunk-P3ZDE6LZ.js} +23 -0
- package/dist/index.cjs +23 -0
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/react.cjs +32 -1
- package/dist/react.d.cts +3 -1
- package/dist/react.d.ts +3 -1
- package/dist/react.js +10 -2
- package/dist/{websocket-BYnhkMSH.d.cts → websocket-Cy0Y29CW.d.cts} +23 -0
- package/dist/{websocket-BYnhkMSH.d.ts → websocket-Cy0Y29CW.d.ts} +23 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4344](https://github.com/snowcone-app/snowcone-monorepo/pull/4344) [`379a042`](https://github.com/snowcone-app/snowcone-monorepo/commit/379a042eb69a26f98fe0050f694c4ccf342e55b8) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Per-placement render versions and an explicit re-render. SDK: `MockupResult.versions` (every placement folded into a frame, from boxes that stamp it), `getLatestSentVersions()`, and `rerender(mockupIds)` (answered by `rerender_queued`; refusals are typed `E_RERENDER_*` errors). UI: a picture's `data-render-state` is `current` only when every placement is at its latest sent version, and a picture whose cropped frame failed is re-rendered with `rerender` once the box stamps versions (falling back to forcing it with configs on an `E_RERENDER_*` refusal or an older box).
|
|
8
|
+
|
|
9
|
+
## 0.24.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#4283](https://github.com/snowcone-app/snowcone-monorepo/pull/4283) [`4fbaaf1`](https://github.com/snowcone-app/snowcone-monorepo/commit/4fbaaf161d0c580a1c56790a9a4c54f676a92abc) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Examples and tool descriptions use live demo products: the iPhone 17 Pro Max Case (`BC43BE`), the Canvas Tote (`CAXHQC`) and the All-Over Print Zip Hoodie (`XTNA6J`), in place of the Framed Canvas (`BEEB77`) and Women's Tee (`KMYKUK`), which are no longer for sale. No API change.
|
|
14
|
+
|
|
3
15
|
## 0.24.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ import { getProduct, listProducts, getMockupUrl } from '@snowcone-app/sdk';
|
|
|
27
27
|
|
|
28
28
|
// 1. Find a product (public catalog read — no key needed)
|
|
29
29
|
const products = await listProducts({ limit: 10 });
|
|
30
|
-
const product = await getProduct('
|
|
30
|
+
const product = await getProduct('BC43BE'); // by id or slug
|
|
31
31
|
|
|
32
32
|
// 2. Build a mockup URL. A mockup is a PUBLIC image URL — getMockupUrl is a
|
|
33
33
|
// pure, synchronous builder (no await, no fetch, no secret). The result
|
|
@@ -66,7 +66,7 @@ const products = await listProducts(options?: {
|
|
|
66
66
|
**Product Object Structure:**
|
|
67
67
|
```typescript
|
|
68
68
|
{
|
|
69
|
-
id: string; // Product ID (e.g., "
|
|
69
|
+
id: string; // Product ID (e.g., "BC43BE")
|
|
70
70
|
name: string; // Product name
|
|
71
71
|
description?: string; // Product description
|
|
72
72
|
basePrice: number; // Base price in cents
|
|
@@ -126,16 +126,16 @@ type Design = Record<string, Fill>; // placement key → fill
|
|
|
126
126
|
#### Multi-placement + variant options
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
|
-
// A front + back
|
|
130
|
-
const url = getMockupUrl('
|
|
129
|
+
// A hoodie's left front + back, size M.
|
|
130
|
+
const url = getMockupUrl('XTNA6J', {
|
|
131
131
|
shop: shop.id,
|
|
132
132
|
options: { size: 'm' },
|
|
133
133
|
design: {
|
|
134
|
-
|
|
134
|
+
front_left: 'https://cdn.example.com/front.png',
|
|
135
135
|
back: { src: 'https://cdn.example.com/back.png', tile: 2, align: 'top' },
|
|
136
136
|
},
|
|
137
137
|
});
|
|
138
|
-
// → …/
|
|
138
|
+
// → …/XTNA6J?shop=…&asset.back=…&tile.back=2&align.back=top&asset.front_left=…&opt.size=m
|
|
139
139
|
|
|
140
140
|
// A cap with a printed front + chosen Crown/Strap colors (color placements).
|
|
141
141
|
const cap = getMockupUrl('RQNU68', {
|
|
@@ -211,7 +211,7 @@ const session = new RenderSession({
|
|
|
211
211
|
grantUrl: '/api/realtime/grant', // your proxy above
|
|
212
212
|
// mockupIds are catalog SCENE CODES (product.mockups[].id) — not placement
|
|
213
213
|
// names. variantId is required for products with a color/size option.
|
|
214
|
-
product: { productId: '
|
|
214
|
+
product: { productId: 'BC43BE', mockupIds: ['947QAD'], variantId: 'e92f40' },
|
|
215
215
|
});
|
|
216
216
|
|
|
217
217
|
session.onMockups((results) => { img.src = results[0].imageUrl; });
|
|
@@ -262,6 +262,9 @@ var RealtimeMockupService = class {
|
|
|
262
262
|
case "have_all_blobs":
|
|
263
263
|
this.addLog("\u{1F389} All blobs received! Starting render...");
|
|
264
264
|
break;
|
|
265
|
+
case "rerender_queued":
|
|
266
|
+
this.addLog(`\u{1F501} Re-render queued for [${(data.mockupIds ?? []).join(", ")}]`, "received");
|
|
267
|
+
break;
|
|
265
268
|
case "rendering_started":
|
|
266
269
|
this.addLog("\u{1F3A8} Mockup rendering has started...");
|
|
267
270
|
break;
|
|
@@ -290,6 +293,7 @@ var RealtimeMockupService = class {
|
|
|
290
293
|
requestId: data.requestId,
|
|
291
294
|
requestVersion: responseVersion,
|
|
292
295
|
placement: responsePlacement,
|
|
296
|
+
...data.versions && typeof data.versions === "object" ? { versions: data.versions } : {},
|
|
293
297
|
renderMs: data.renderMs,
|
|
294
298
|
blobToRenderMs: data.blobToRenderMs,
|
|
295
299
|
costUsd: data.costUsd,
|
|
@@ -761,6 +765,25 @@ ${versionToSend}
|
|
|
761
765
|
* send a frame belongs to — the pipeline-depth send policy counts a send
|
|
762
766
|
* as landed when every mockup of its version has arrived.
|
|
763
767
|
*/
|
|
768
|
+
/** The latest canvas version sent per placement (copy). */
|
|
769
|
+
getLatestSentVersions() {
|
|
770
|
+
return { ...this.latestSentVersionByPlacement };
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Re-render these mockups now from the session's current state (servers with
|
|
774
|
+
* the `rerender` message). Answered by `rerender_queued` and then one
|
|
775
|
+
* mockup_rendered per mockup; refusals arrive as typed errors
|
|
776
|
+
* (E_RERENDER_NOT_CONFIGURED | E_RERENDER_BAD_REQUEST | E_RERENDER_UNKNOWN_MOCKUP |
|
|
777
|
+
* E_RERENDER_INCOMPLETE | E_RERENDER_RATE_LIMITED). Never changes the
|
|
778
|
+
* session's mockupIds.
|
|
779
|
+
*/
|
|
780
|
+
rerender(mockupIds) {
|
|
781
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN || !this.config || mockupIds.length === 0) return false;
|
|
782
|
+
const { requestId, traceparent } = newRenderCorrelation();
|
|
783
|
+
this.ws.send(JSON.stringify({ type: "rerender", mockupIds, requestId, traceparent }));
|
|
784
|
+
this.addLog(`\u{1F501} Re-render requested for [${mockupIds.join(", ")}] (req ${requestId})`, "sent");
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
764
787
|
getLastSentVersion() {
|
|
765
788
|
return this.lastSentVersion;
|
|
766
789
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -5292,6 +5292,9 @@ var RealtimeMockupService = class {
|
|
|
5292
5292
|
case "have_all_blobs":
|
|
5293
5293
|
this.addLog("\u{1F389} All blobs received! Starting render...");
|
|
5294
5294
|
break;
|
|
5295
|
+
case "rerender_queued":
|
|
5296
|
+
this.addLog(`\u{1F501} Re-render queued for [${(data.mockupIds ?? []).join(", ")}]`, "received");
|
|
5297
|
+
break;
|
|
5295
5298
|
case "rendering_started":
|
|
5296
5299
|
this.addLog("\u{1F3A8} Mockup rendering has started...");
|
|
5297
5300
|
break;
|
|
@@ -5320,6 +5323,7 @@ var RealtimeMockupService = class {
|
|
|
5320
5323
|
requestId: data.requestId,
|
|
5321
5324
|
requestVersion: responseVersion,
|
|
5322
5325
|
placement: responsePlacement,
|
|
5326
|
+
...data.versions && typeof data.versions === "object" ? { versions: data.versions } : {},
|
|
5323
5327
|
renderMs: data.renderMs,
|
|
5324
5328
|
blobToRenderMs: data.blobToRenderMs,
|
|
5325
5329
|
costUsd: data.costUsd,
|
|
@@ -5791,6 +5795,25 @@ ${versionToSend}
|
|
|
5791
5795
|
* send a frame belongs to — the pipeline-depth send policy counts a send
|
|
5792
5796
|
* as landed when every mockup of its version has arrived.
|
|
5793
5797
|
*/
|
|
5798
|
+
/** The latest canvas version sent per placement (copy). */
|
|
5799
|
+
getLatestSentVersions() {
|
|
5800
|
+
return { ...this.latestSentVersionByPlacement };
|
|
5801
|
+
}
|
|
5802
|
+
/**
|
|
5803
|
+
* Re-render these mockups now from the session's current state (servers with
|
|
5804
|
+
* the `rerender` message). Answered by `rerender_queued` and then one
|
|
5805
|
+
* mockup_rendered per mockup; refusals arrive as typed errors
|
|
5806
|
+
* (E_RERENDER_NOT_CONFIGURED | E_RERENDER_BAD_REQUEST | E_RERENDER_UNKNOWN_MOCKUP |
|
|
5807
|
+
* E_RERENDER_INCOMPLETE | E_RERENDER_RATE_LIMITED). Never changes the
|
|
5808
|
+
* session's mockupIds.
|
|
5809
|
+
*/
|
|
5810
|
+
rerender(mockupIds) {
|
|
5811
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN || !this.config || mockupIds.length === 0) return false;
|
|
5812
|
+
const { requestId, traceparent } = newRenderCorrelation();
|
|
5813
|
+
this.ws.send(JSON.stringify({ type: "rerender", mockupIds, requestId, traceparent }));
|
|
5814
|
+
this.addLog(`\u{1F501} Re-render requested for [${mockupIds.join(", ")}] (req ${requestId})`, "sent");
|
|
5815
|
+
return true;
|
|
5816
|
+
}
|
|
5794
5817
|
getLastSentVersion() {
|
|
5795
5818
|
return this.lastSentVersion;
|
|
5796
5819
|
}
|
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 RealtimeRenderError, h as RealtimeMockupService } from './websocket-
|
|
4
|
-
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-
|
|
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 RealtimeRenderError, h as RealtimeMockupService } from './websocket-Cy0Y29CW.cjs';
|
|
4
|
+
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-Cy0Y29CW.cjs';
|
|
5
5
|
|
|
6
6
|
interface CatalogProduct {
|
|
7
7
|
id: string;
|
|
@@ -401,7 +401,7 @@ interface GetMockupUrlOptions {
|
|
|
401
401
|
*
|
|
402
402
|
* // Code-first (preferred): productCode then options.
|
|
403
403
|
* getMockupUrl("hoodie-black", { shop, asset });
|
|
404
|
-
* getMockupUrl("
|
|
404
|
+
* getMockupUrl("XTNA6J", { shop, options: { size: "m" }, design: {…} });
|
|
405
405
|
*
|
|
406
406
|
* // Legacy positional: (assetUrl, productCode, opts).
|
|
407
407
|
* getMockupUrl(assetUrl, "hoodie-black", { shop });
|
|
@@ -419,8 +419,8 @@ declare const DEFAULT_BUY_BASE = "https://buy.snowcone.app";
|
|
|
419
419
|
* where the mockup URL renders the design as an image, this URL opens the
|
|
420
420
|
* Snowcone-hosted checkout with that exact design in the cart.
|
|
421
421
|
*
|
|
422
|
-
* const img = getMockupUrl("
|
|
423
|
-
* const buy = getBuyUrl("
|
|
422
|
+
* const img = getMockupUrl("BC43BE", { shop, asset }); // the picture
|
|
423
|
+
* const buy = getBuyUrl("BC43BE", { shop, asset }); // the purchase
|
|
424
424
|
*
|
|
425
425
|
* Pure + synchronous, like `getMockupUrl` — drop the result into an
|
|
426
426
|
* `<a href>`. Pass `base` to override the host.
|
|
@@ -2876,7 +2876,7 @@ declare function fetchRealtimeGrant(grantUrl: string, shop: string, fetchImpl?:
|
|
|
2876
2876
|
* grantUrl: '/api/realtime/grant', // your proxy → mintRealtimeGrant (server)
|
|
2877
2877
|
* // mockupIds are opaque catalog SCENE CODES (product.mockups[].id) — NOT
|
|
2878
2878
|
* // placement names. variantId is required for products with a color/size axis.
|
|
2879
|
-
* product: { productId: '
|
|
2879
|
+
* product: { productId: 'BC43BE', mockupIds: ['947QAD'], variantId: 'e92f40' },
|
|
2880
2880
|
* });
|
|
2881
2881
|
* session.onMockups((results) => { img.src = results[0].imageUrl; });
|
|
2882
2882
|
* // First arg is the PLACEMENT name (placements[].label, e.g. 'Front') — a
|
|
@@ -2919,11 +2919,11 @@ interface DesignLike {
|
|
|
2919
2919
|
interface RenderProductCombination {
|
|
2920
2920
|
/** The variant (gvid) this combination resolves to. */
|
|
2921
2921
|
variantId?: string;
|
|
2922
|
-
/** Attribute selections (e.g. `{
|
|
2922
|
+
/** Attribute selections (e.g. `{ Size: 'M', color: 'Black' }`). */
|
|
2923
2923
|
[attribute: string]: string | number | undefined;
|
|
2924
2924
|
}
|
|
2925
2925
|
/**
|
|
2926
|
-
* One choice of a variant attribute (e.g. `{ label: '
|
|
2926
|
+
* One choice of a variant attribute (e.g. `{ label: 'Black', hex: '#000000' }`).
|
|
2927
2927
|
* A `hex` value marks the attribute as a COLOR axis — the one kind of variant
|
|
2928
2928
|
* the renderer treats as a required placement (auto-filled from `variantId`).
|
|
2929
2929
|
*/
|
|
@@ -2991,7 +2991,7 @@ interface RenderProduct {
|
|
|
2991
2991
|
productId: string;
|
|
2992
2992
|
/**
|
|
2993
2993
|
* The mockup scenes to render — opaque catalog codes (the product's
|
|
2994
|
-
* `mockups[].id`, e.g. `'
|
|
2994
|
+
* `mockups[].id`, e.g. `'947QAD'`). These are a DIFFERENT namespace from the
|
|
2995
2995
|
* `placement` you pass to {@link RenderSession.renderState} (a print-area name
|
|
2996
2996
|
* like `'Front'`). Don't pass a placement name here.
|
|
2997
2997
|
*/
|
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 RealtimeRenderError, h as RealtimeMockupService } from './websocket-
|
|
4
|
-
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-
|
|
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 RealtimeRenderError, h as RealtimeMockupService } from './websocket-Cy0Y29CW.js';
|
|
4
|
+
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-Cy0Y29CW.js';
|
|
5
5
|
|
|
6
6
|
interface CatalogProduct {
|
|
7
7
|
id: string;
|
|
@@ -401,7 +401,7 @@ interface GetMockupUrlOptions {
|
|
|
401
401
|
*
|
|
402
402
|
* // Code-first (preferred): productCode then options.
|
|
403
403
|
* getMockupUrl("hoodie-black", { shop, asset });
|
|
404
|
-
* getMockupUrl("
|
|
404
|
+
* getMockupUrl("XTNA6J", { shop, options: { size: "m" }, design: {…} });
|
|
405
405
|
*
|
|
406
406
|
* // Legacy positional: (assetUrl, productCode, opts).
|
|
407
407
|
* getMockupUrl(assetUrl, "hoodie-black", { shop });
|
|
@@ -419,8 +419,8 @@ declare const DEFAULT_BUY_BASE = "https://buy.snowcone.app";
|
|
|
419
419
|
* where the mockup URL renders the design as an image, this URL opens the
|
|
420
420
|
* Snowcone-hosted checkout with that exact design in the cart.
|
|
421
421
|
*
|
|
422
|
-
* const img = getMockupUrl("
|
|
423
|
-
* const buy = getBuyUrl("
|
|
422
|
+
* const img = getMockupUrl("BC43BE", { shop, asset }); // the picture
|
|
423
|
+
* const buy = getBuyUrl("BC43BE", { shop, asset }); // the purchase
|
|
424
424
|
*
|
|
425
425
|
* Pure + synchronous, like `getMockupUrl` — drop the result into an
|
|
426
426
|
* `<a href>`. Pass `base` to override the host.
|
|
@@ -2876,7 +2876,7 @@ declare function fetchRealtimeGrant(grantUrl: string, shop: string, fetchImpl?:
|
|
|
2876
2876
|
* grantUrl: '/api/realtime/grant', // your proxy → mintRealtimeGrant (server)
|
|
2877
2877
|
* // mockupIds are opaque catalog SCENE CODES (product.mockups[].id) — NOT
|
|
2878
2878
|
* // placement names. variantId is required for products with a color/size axis.
|
|
2879
|
-
* product: { productId: '
|
|
2879
|
+
* product: { productId: 'BC43BE', mockupIds: ['947QAD'], variantId: 'e92f40' },
|
|
2880
2880
|
* });
|
|
2881
2881
|
* session.onMockups((results) => { img.src = results[0].imageUrl; });
|
|
2882
2882
|
* // First arg is the PLACEMENT name (placements[].label, e.g. 'Front') — a
|
|
@@ -2919,11 +2919,11 @@ interface DesignLike {
|
|
|
2919
2919
|
interface RenderProductCombination {
|
|
2920
2920
|
/** The variant (gvid) this combination resolves to. */
|
|
2921
2921
|
variantId?: string;
|
|
2922
|
-
/** Attribute selections (e.g. `{
|
|
2922
|
+
/** Attribute selections (e.g. `{ Size: 'M', color: 'Black' }`). */
|
|
2923
2923
|
[attribute: string]: string | number | undefined;
|
|
2924
2924
|
}
|
|
2925
2925
|
/**
|
|
2926
|
-
* One choice of a variant attribute (e.g. `{ label: '
|
|
2926
|
+
* One choice of a variant attribute (e.g. `{ label: 'Black', hex: '#000000' }`).
|
|
2927
2927
|
* A `hex` value marks the attribute as a COLOR axis — the one kind of variant
|
|
2928
2928
|
* the renderer treats as a required placement (auto-filled from `variantId`).
|
|
2929
2929
|
*/
|
|
@@ -2991,7 +2991,7 @@ interface RenderProduct {
|
|
|
2991
2991
|
productId: string;
|
|
2992
2992
|
/**
|
|
2993
2993
|
* The mockup scenes to render — opaque catalog codes (the product's
|
|
2994
|
-
* `mockups[].id`, e.g. `'
|
|
2994
|
+
* `mockups[].id`, e.g. `'947QAD'`). These are a DIFFERENT namespace from the
|
|
2995
2995
|
* `placement` you pass to {@link RenderSession.renderState} (a print-area name
|
|
2996
2996
|
* like `'Front'`). Don't pass a placement name here.
|
|
2997
2997
|
*/
|
package/dist/index.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -296,6 +296,9 @@ var RealtimeMockupService = class {
|
|
|
296
296
|
case "have_all_blobs":
|
|
297
297
|
this.addLog("\u{1F389} All blobs received! Starting render...");
|
|
298
298
|
break;
|
|
299
|
+
case "rerender_queued":
|
|
300
|
+
this.addLog(`\u{1F501} Re-render queued for [${(data.mockupIds ?? []).join(", ")}]`, "received");
|
|
301
|
+
break;
|
|
299
302
|
case "rendering_started":
|
|
300
303
|
this.addLog("\u{1F3A8} Mockup rendering has started...");
|
|
301
304
|
break;
|
|
@@ -324,6 +327,7 @@ var RealtimeMockupService = class {
|
|
|
324
327
|
requestId: data.requestId,
|
|
325
328
|
requestVersion: responseVersion,
|
|
326
329
|
placement: responsePlacement,
|
|
330
|
+
...data.versions && typeof data.versions === "object" ? { versions: data.versions } : {},
|
|
327
331
|
renderMs: data.renderMs,
|
|
328
332
|
blobToRenderMs: data.blobToRenderMs,
|
|
329
333
|
costUsd: data.costUsd,
|
|
@@ -795,6 +799,25 @@ ${versionToSend}
|
|
|
795
799
|
* send a frame belongs to — the pipeline-depth send policy counts a send
|
|
796
800
|
* as landed when every mockup of its version has arrived.
|
|
797
801
|
*/
|
|
802
|
+
/** The latest canvas version sent per placement (copy). */
|
|
803
|
+
getLatestSentVersions() {
|
|
804
|
+
return { ...this.latestSentVersionByPlacement };
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Re-render these mockups now from the session's current state (servers with
|
|
808
|
+
* the `rerender` message). Answered by `rerender_queued` and then one
|
|
809
|
+
* mockup_rendered per mockup; refusals arrive as typed errors
|
|
810
|
+
* (E_RERENDER_NOT_CONFIGURED | E_RERENDER_BAD_REQUEST | E_RERENDER_UNKNOWN_MOCKUP |
|
|
811
|
+
* E_RERENDER_INCOMPLETE | E_RERENDER_RATE_LIMITED). Never changes the
|
|
812
|
+
* session's mockupIds.
|
|
813
|
+
*/
|
|
814
|
+
rerender(mockupIds) {
|
|
815
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN || !this.config || mockupIds.length === 0) return false;
|
|
816
|
+
const { requestId, traceparent } = newRenderCorrelation();
|
|
817
|
+
this.ws.send(JSON.stringify({ type: "rerender", mockupIds, requestId, traceparent }));
|
|
818
|
+
this.addLog(`\u{1F501} Re-render requested for [${mockupIds.join(", ")}] (req ${requestId})`, "sent");
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
798
821
|
getLastSentVersion() {
|
|
799
822
|
return this.lastSentVersion;
|
|
800
823
|
}
|
|
@@ -1007,6 +1030,12 @@ function useRealtimeMockup(options = {}) {
|
|
|
1007
1030
|
const hasPendingBlobs = (0, import_react.useCallback)(() => {
|
|
1008
1031
|
return serviceRef.current?.hasPendingBlobs() || false;
|
|
1009
1032
|
}, []);
|
|
1033
|
+
const getLatestSentVersions = (0, import_react.useCallback)(() => {
|
|
1034
|
+
return serviceRef.current?.getLatestSentVersions() ?? {};
|
|
1035
|
+
}, []);
|
|
1036
|
+
const rerender = (0, import_react.useCallback)((mockupIds) => {
|
|
1037
|
+
return serviceRef.current?.rerender(mockupIds) ?? false;
|
|
1038
|
+
}, []);
|
|
1010
1039
|
const getLastSentVersion = (0, import_react.useCallback)(() => {
|
|
1011
1040
|
return serviceRef.current?.getLastSentVersion() ?? 0;
|
|
1012
1041
|
}, []);
|
|
@@ -1028,7 +1057,9 @@ function useRealtimeMockup(options = {}) {
|
|
|
1028
1057
|
clearMockups,
|
|
1029
1058
|
flushPendingBlobs,
|
|
1030
1059
|
hasPendingBlobs,
|
|
1031
|
-
getLastSentVersion
|
|
1060
|
+
getLastSentVersion,
|
|
1061
|
+
getLatestSentVersions,
|
|
1062
|
+
rerender
|
|
1032
1063
|
};
|
|
1033
1064
|
}
|
|
1034
1065
|
|
package/dist/react.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MockupResult, R as RealtimeRenderError, 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-
|
|
1
|
+
import { M as MockupResult, R as RealtimeRenderError, 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-Cy0Y29CW.cjs';
|
|
2
2
|
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface UseRealtimeMockupOptions {
|
|
@@ -54,6 +54,8 @@ declare function useRealtimeMockup(options?: UseRealtimeMockupOptions): {
|
|
|
54
54
|
flushPendingBlobs: () => void;
|
|
55
55
|
hasPendingBlobs: () => boolean;
|
|
56
56
|
getLastSentVersion: () => number;
|
|
57
|
+
getLatestSentVersions: () => Record<string, number>;
|
|
58
|
+
rerender: (mockupIds: string[]) => boolean;
|
|
57
59
|
isConnected: boolean;
|
|
58
60
|
sessionId: string | null;
|
|
59
61
|
box: string | null;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MockupResult, R as RealtimeRenderError, 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-
|
|
1
|
+
import { M as MockupResult, R as RealtimeRenderError, 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-Cy0Y29CW.js';
|
|
2
2
|
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface UseRealtimeMockupOptions {
|
|
@@ -54,6 +54,8 @@ declare function useRealtimeMockup(options?: UseRealtimeMockupOptions): {
|
|
|
54
54
|
flushPendingBlobs: () => void;
|
|
55
55
|
hasPendingBlobs: () => boolean;
|
|
56
56
|
getLastSentVersion: () => number;
|
|
57
|
+
getLatestSentVersions: () => Record<string, number>;
|
|
58
|
+
rerender: (mockupIds: string[]) => boolean;
|
|
57
59
|
isConnected: boolean;
|
|
58
60
|
sessionId: string | null;
|
|
59
61
|
box: string | null;
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RealtimeMockupService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P3ZDE6LZ.js";
|
|
4
4
|
|
|
5
5
|
// src/realtime/react.ts
|
|
6
6
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -117,6 +117,12 @@ function useRealtimeMockup(options = {}) {
|
|
|
117
117
|
const hasPendingBlobs = useCallback(() => {
|
|
118
118
|
return serviceRef.current?.hasPendingBlobs() || false;
|
|
119
119
|
}, []);
|
|
120
|
+
const getLatestSentVersions = useCallback(() => {
|
|
121
|
+
return serviceRef.current?.getLatestSentVersions() ?? {};
|
|
122
|
+
}, []);
|
|
123
|
+
const rerender = useCallback((mockupIds) => {
|
|
124
|
+
return serviceRef.current?.rerender(mockupIds) ?? false;
|
|
125
|
+
}, []);
|
|
120
126
|
const getLastSentVersion = useCallback(() => {
|
|
121
127
|
return serviceRef.current?.getLastSentVersion() ?? 0;
|
|
122
128
|
}, []);
|
|
@@ -138,7 +144,9 @@ function useRealtimeMockup(options = {}) {
|
|
|
138
144
|
clearMockups,
|
|
139
145
|
flushPendingBlobs,
|
|
140
146
|
hasPendingBlobs,
|
|
141
|
-
getLastSentVersion
|
|
147
|
+
getLastSentVersion,
|
|
148
|
+
getLatestSentVersions,
|
|
149
|
+
rerender
|
|
142
150
|
};
|
|
143
151
|
}
|
|
144
152
|
|
|
@@ -303,6 +303,14 @@ interface MockupResult {
|
|
|
303
303
|
requestVersion?: number;
|
|
304
304
|
/** The placement this mockup corresponds to */
|
|
305
305
|
placement?: string;
|
|
306
|
+
/**
|
|
307
|
+
* Every canvas_state placement folded into this frame, with the version the
|
|
308
|
+
* box used for it (servers with per-placement stamps; then `requestVersion`
|
|
309
|
+
* is their max). A frame is current when, for every placement this session
|
|
310
|
+
* sent, `versions[placement]` is at least the latest version sent for it
|
|
311
|
+
* (see {@link RealtimeMockupService.getLatestSentVersions}).
|
|
312
|
+
*/
|
|
313
|
+
versions?: Record<string, number>;
|
|
306
314
|
/** Server-side render time in ms */
|
|
307
315
|
renderMs?: number;
|
|
308
316
|
/** Time from blob received to render start in ms */
|
|
@@ -349,6 +357,10 @@ interface WebSocketMessage {
|
|
|
349
357
|
imageUrl?: string;
|
|
350
358
|
renderUrl?: string;
|
|
351
359
|
mockupId?: string;
|
|
360
|
+
/** `rerender_queued`: the mockups the box queued. */
|
|
361
|
+
mockupIds?: string[];
|
|
362
|
+
/** Per-placement versions folded into a frame (see MockupResult.versions). */
|
|
363
|
+
versions?: Record<string, number>;
|
|
352
364
|
imageSize?: number;
|
|
353
365
|
message?: string;
|
|
354
366
|
/** Machine-readable error code on `type: 'error'` frames (e.g. 'asset_not_allowed') */
|
|
@@ -568,6 +580,17 @@ declare class RealtimeMockupService {
|
|
|
568
580
|
* send a frame belongs to — the pipeline-depth send policy counts a send
|
|
569
581
|
* as landed when every mockup of its version has arrived.
|
|
570
582
|
*/
|
|
583
|
+
/** The latest canvas version sent per placement (copy). */
|
|
584
|
+
getLatestSentVersions(): Record<string, number>;
|
|
585
|
+
/**
|
|
586
|
+
* Re-render these mockups now from the session's current state (servers with
|
|
587
|
+
* the `rerender` message). Answered by `rerender_queued` and then one
|
|
588
|
+
* mockup_rendered per mockup; refusals arrive as typed errors
|
|
589
|
+
* (E_RERENDER_NOT_CONFIGURED | E_RERENDER_BAD_REQUEST | E_RERENDER_UNKNOWN_MOCKUP |
|
|
590
|
+
* E_RERENDER_INCOMPLETE | E_RERENDER_RATE_LIMITED). Never changes the
|
|
591
|
+
* session's mockupIds.
|
|
592
|
+
*/
|
|
593
|
+
rerender(mockupIds: string[]): boolean;
|
|
571
594
|
getLastSentVersion(): number;
|
|
572
595
|
sendColorBlob(placement: string, hexColor: string): boolean;
|
|
573
596
|
createEmptyCanvasBlob(width?: number, height?: number): Promise<Blob>;
|
|
@@ -303,6 +303,14 @@ interface MockupResult {
|
|
|
303
303
|
requestVersion?: number;
|
|
304
304
|
/** The placement this mockup corresponds to */
|
|
305
305
|
placement?: string;
|
|
306
|
+
/**
|
|
307
|
+
* Every canvas_state placement folded into this frame, with the version the
|
|
308
|
+
* box used for it (servers with per-placement stamps; then `requestVersion`
|
|
309
|
+
* is their max). A frame is current when, for every placement this session
|
|
310
|
+
* sent, `versions[placement]` is at least the latest version sent for it
|
|
311
|
+
* (see {@link RealtimeMockupService.getLatestSentVersions}).
|
|
312
|
+
*/
|
|
313
|
+
versions?: Record<string, number>;
|
|
306
314
|
/** Server-side render time in ms */
|
|
307
315
|
renderMs?: number;
|
|
308
316
|
/** Time from blob received to render start in ms */
|
|
@@ -349,6 +357,10 @@ interface WebSocketMessage {
|
|
|
349
357
|
imageUrl?: string;
|
|
350
358
|
renderUrl?: string;
|
|
351
359
|
mockupId?: string;
|
|
360
|
+
/** `rerender_queued`: the mockups the box queued. */
|
|
361
|
+
mockupIds?: string[];
|
|
362
|
+
/** Per-placement versions folded into a frame (see MockupResult.versions). */
|
|
363
|
+
versions?: Record<string, number>;
|
|
352
364
|
imageSize?: number;
|
|
353
365
|
message?: string;
|
|
354
366
|
/** Machine-readable error code on `type: 'error'` frames (e.g. 'asset_not_allowed') */
|
|
@@ -568,6 +580,17 @@ declare class RealtimeMockupService {
|
|
|
568
580
|
* send a frame belongs to — the pipeline-depth send policy counts a send
|
|
569
581
|
* as landed when every mockup of its version has arrived.
|
|
570
582
|
*/
|
|
583
|
+
/** The latest canvas version sent per placement (copy). */
|
|
584
|
+
getLatestSentVersions(): Record<string, number>;
|
|
585
|
+
/**
|
|
586
|
+
* Re-render these mockups now from the session's current state (servers with
|
|
587
|
+
* the `rerender` message). Answered by `rerender_queued` and then one
|
|
588
|
+
* mockup_rendered per mockup; refusals arrive as typed errors
|
|
589
|
+
* (E_RERENDER_NOT_CONFIGURED | E_RERENDER_BAD_REQUEST | E_RERENDER_UNKNOWN_MOCKUP |
|
|
590
|
+
* E_RERENDER_INCOMPLETE | E_RERENDER_RATE_LIMITED). Never changes the
|
|
591
|
+
* session's mockupIds.
|
|
592
|
+
*/
|
|
593
|
+
rerender(mockupIds: string[]): boolean;
|
|
571
594
|
getLastSentVersion(): number;
|
|
572
595
|
sendColorBlob(placement: string, hexColor: string): boolean;
|
|
573
596
|
createEmptyCanvasBlob(width?: number, height?: number): Promise<Blob>;
|