@snowcone-app/sdk 0.12.0 → 0.13.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 +38 -0
- package/dist/{chunk-LYLIDU6G.js → chunk-QHRQ3VJD.js} +0 -4
- package/dist/index.cjs +52 -89
- package/dist/index.d.cts +63 -10
- package/dist/index.d.ts +63 -10
- package/dist/index.js +52 -86
- package/dist/react.cjs +0 -4
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/{websocket-X4tcUm78.d.cts → websocket-Bfc3nsyG.d.cts} +0 -1
- package/dist/{websocket-X4tcUm78.d.ts → websocket-Bfc3nsyG.d.ts} +0 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#625](https://github.com/snowcone-app/snowcone-monorepo/pull/625) [`1f9e32d`](https://github.com/snowcone-app/snowcone-monorepo/commit/1f9e32d65a53cd9be2fea4f858cba485837f19e7) Thanks [@kevinsproles](https://github.com/kevinsproles)! - New `searchDesigns(query, options)` + `client.catalog.designs.search()` for the
|
|
8
|
+
public pre-made designs catalog (`snowcone-designs` Meilisearch index), with
|
|
9
|
+
`meilisearch.designsIndex` config / `NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX` env
|
|
10
|
+
override and a loose `CatalogDesign` type carrying mockup-URL components
|
|
11
|
+
(`productId`, `asset`, `assets`, `variant`, reserved `slots`).
|
|
12
|
+
|
|
13
|
+
## 0.12.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#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).
|
|
18
|
+
|
|
19
|
+
New on `@snowcone-app/canvas/embed`: `Editor.Root` / `Editor.Canvas` /
|
|
20
|
+
`Editor.Preview` / `Editor.TextField` / `Editor.Buy` — compound parts over one
|
|
21
|
+
Root; the host owns all layout. Includes the typed layer-token API
|
|
22
|
+
(`design.layer("name")` — compile-checked against the design's layer names,
|
|
23
|
+
runtime-validated for JSON-loaded designs), the one live design-state store
|
|
24
|
+
(seeded from the design, updated by canvas edits AND TextField writes,
|
|
25
|
+
last-write-wins), smart Buy (completeness rules + payload assembled from
|
|
26
|
+
design state), structured `EditorError` codes, and Root's built-in error
|
|
27
|
+
boundary. **All `Editor.*` exports are `@experimental`** — the API may change
|
|
28
|
+
in minors until the default editor is rebuilt from these public parts.
|
|
29
|
+
|
|
30
|
+
Existing turnkey API unchanged in meaning: `RealtimeEmbed` is now a thin
|
|
31
|
+
wrapper over `Editor.Root` (same behavior, advisory validation),
|
|
32
|
+
`RealtimeMockup` over `Editor.Preview`. One behavior note: `RealtimeCanvas`'s
|
|
33
|
+
implementation moved into the shared lazy renderer chunk — the embed entry's
|
|
34
|
+
static import graph is now renderer-free (a no-canvas page never downloads
|
|
35
|
+
the rendering engine; CI-enforced), and the canvas mounts one chunk-fetch
|
|
36
|
+
after first paint. The floating contextual toolbar now tracks page/container
|
|
37
|
+
scroll (it previously drifted on scrolling host pages).
|
|
38
|
+
|
|
39
|
+
sdk: internal dead-code cleanup (no API change).
|
|
40
|
+
|
|
3
41
|
## 0.12.0
|
|
4
42
|
|
|
5
43
|
### Minor Changes
|
|
@@ -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
|
@@ -136,6 +136,7 @@ __export(index_exports, {
|
|
|
136
136
|
resolveMockupId: () => resolveMockupId,
|
|
137
137
|
resolveVariantId: () => resolveVariantId,
|
|
138
138
|
retryOperation: () => retryOperation,
|
|
139
|
+
searchDesigns: () => searchDesigns,
|
|
139
140
|
simulateCartOperation: () => simulateCartOperation,
|
|
140
141
|
toCombinations: () => toCombinations,
|
|
141
142
|
toOptionAttributes: () => toOptionAttributes,
|
|
@@ -410,59 +411,6 @@ var MockupServiceImpl = class {
|
|
|
410
411
|
}
|
|
411
412
|
return url;
|
|
412
413
|
}
|
|
413
|
-
buildMockupUrl(options) {
|
|
414
|
-
const { design, product, effects } = options;
|
|
415
|
-
const pathSegments = ["m"];
|
|
416
|
-
pathSegments.push(product.productId);
|
|
417
|
-
pathSegments.push(product.mockupId);
|
|
418
|
-
pathSegments.push(product.variantId);
|
|
419
|
-
pathSegments.push(String(product.width));
|
|
420
|
-
const designParts = [];
|
|
421
|
-
for (const element of design) {
|
|
422
|
-
const part = this.encodeDesignElement(element);
|
|
423
|
-
designParts.push(part);
|
|
424
|
-
}
|
|
425
|
-
if (designParts.length > 0) {
|
|
426
|
-
pathSegments.push(designParts.join("_"));
|
|
427
|
-
} else {
|
|
428
|
-
pathSegments.push("");
|
|
429
|
-
}
|
|
430
|
-
if (effects?.grain) {
|
|
431
|
-
pathSegments.push(`g${effects.grain}`);
|
|
432
|
-
}
|
|
433
|
-
return "/" + pathSegments.join("/");
|
|
434
|
-
}
|
|
435
|
-
encodeDesignElement(element) {
|
|
436
|
-
const parts = [];
|
|
437
|
-
if (element.type === "image") {
|
|
438
|
-
const encodedUrl = this.encodeImageUrl(element.imageUrl);
|
|
439
|
-
parts.push(encodedUrl);
|
|
440
|
-
parts.push(element.placement);
|
|
441
|
-
parts.push(String(element.width));
|
|
442
|
-
parts.push(String(element.height));
|
|
443
|
-
parts.push(element.alignment);
|
|
444
|
-
if (element.tiles && element.tiles > 1) {
|
|
445
|
-
parts.push(`t${element.tiles}`);
|
|
446
|
-
}
|
|
447
|
-
} else if (element.type === "color") {
|
|
448
|
-
const colorCode = element.hex.replace("#", "");
|
|
449
|
-
parts.push(colorCode);
|
|
450
|
-
parts.push(element.placement);
|
|
451
|
-
parts.push(String(element.width));
|
|
452
|
-
parts.push(String(element.height));
|
|
453
|
-
parts.push(element.alignment);
|
|
454
|
-
}
|
|
455
|
-
return parts.join(",");
|
|
456
|
-
}
|
|
457
|
-
encodeImageUrl(url) {
|
|
458
|
-
if (typeof window !== "undefined" && window.btoa) {
|
|
459
|
-
const base64 = window.btoa(url);
|
|
460
|
-
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
461
|
-
} else {
|
|
462
|
-
const base64 = Buffer.from(url).toString("base64");
|
|
463
|
-
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
414
|
async getSignedUrl(relativeUrl) {
|
|
467
415
|
const urlWithAccountId = relativeUrl + (relativeUrl.includes("?") ? "&" : "?") + `shop=${encodeURIComponent(this.config.shop)}`;
|
|
468
416
|
const cacheKey = urlWithAccountId;
|
|
@@ -1163,7 +1111,7 @@ var StateManager = class {
|
|
|
1163
1111
|
if (options.debug) {
|
|
1164
1112
|
this.middleware.push({
|
|
1165
1113
|
name: "debug",
|
|
1166
|
-
afterUpdate: (
|
|
1114
|
+
afterUpdate: (_state, _prevState) => {
|
|
1167
1115
|
}
|
|
1168
1116
|
});
|
|
1169
1117
|
}
|
|
@@ -1285,15 +1233,6 @@ var StateManager = class {
|
|
|
1285
1233
|
hasStateChanged(prev, next) {
|
|
1286
1234
|
return JSON.stringify(prev) !== JSON.stringify(next);
|
|
1287
1235
|
}
|
|
1288
|
-
getStateDiff(prev, next) {
|
|
1289
|
-
const diff = {};
|
|
1290
|
-
for (const key in next) {
|
|
1291
|
-
if (prev[key] !== next[key]) {
|
|
1292
|
-
diff[key] = next[key];
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
return diff;
|
|
1296
|
-
}
|
|
1297
1236
|
persistState() {
|
|
1298
1237
|
if (this.options.persist) {
|
|
1299
1238
|
const storage = this.options.persist.storage || localStorage;
|
|
@@ -1594,7 +1533,7 @@ function handleOptionChange(optionKey, newValue, currentSelection, attributes) {
|
|
|
1594
1533
|
);
|
|
1595
1534
|
return clearedSelection;
|
|
1596
1535
|
}
|
|
1597
|
-
function clearDependentSelections(
|
|
1536
|
+
function clearDependentSelections(_changedKey, selection, _attributes) {
|
|
1598
1537
|
return selection;
|
|
1599
1538
|
}
|
|
1600
1539
|
function validateRequiredOptions(selection, attributes) {
|
|
@@ -3196,7 +3135,7 @@ var ContextInjector = class {
|
|
|
3196
3135
|
setContext(key) {
|
|
3197
3136
|
return { key, provider };
|
|
3198
3137
|
},
|
|
3199
|
-
getContext(
|
|
3138
|
+
getContext(_key) {
|
|
3200
3139
|
return provider;
|
|
3201
3140
|
}
|
|
3202
3141
|
};
|
|
@@ -3254,7 +3193,7 @@ function withContext(Base) {
|
|
|
3254
3193
|
onContextError(error) {
|
|
3255
3194
|
console.error("Context error:", error);
|
|
3256
3195
|
}
|
|
3257
|
-
onContextLoading(
|
|
3196
|
+
onContextLoading(_loading) {
|
|
3258
3197
|
}
|
|
3259
3198
|
findProvider() {
|
|
3260
3199
|
return void 0;
|
|
@@ -4355,7 +4294,7 @@ var ComponentFactory = class {
|
|
|
4355
4294
|
* Create a React component
|
|
4356
4295
|
*/
|
|
4357
4296
|
static forReact(definition, React) {
|
|
4358
|
-
const { metadata
|
|
4297
|
+
const { metadata } = definition;
|
|
4359
4298
|
const Component = (props) => {
|
|
4360
4299
|
return React.createElement("div", props);
|
|
4361
4300
|
};
|
|
@@ -4366,12 +4305,12 @@ var ComponentFactory = class {
|
|
|
4366
4305
|
* Create a Vue component
|
|
4367
4306
|
*/
|
|
4368
4307
|
static forVue(definition) {
|
|
4369
|
-
const { metadata
|
|
4308
|
+
const { metadata } = definition;
|
|
4370
4309
|
return {
|
|
4371
4310
|
name: metadata.name,
|
|
4372
4311
|
props: metadata.props,
|
|
4373
4312
|
emits: metadata.events?.map((e) => e.name),
|
|
4374
|
-
setup(
|
|
4313
|
+
setup(_props, _context) {
|
|
4375
4314
|
return () => null;
|
|
4376
4315
|
}
|
|
4377
4316
|
};
|
|
@@ -4389,7 +4328,7 @@ var ComponentFactory = class {
|
|
|
4389
4328
|
* Create a Web Component
|
|
4390
4329
|
*/
|
|
4391
4330
|
static forWebComponent(definition, LitElement) {
|
|
4392
|
-
const { metadata
|
|
4331
|
+
const { metadata } = definition;
|
|
4393
4332
|
class Component extends LitElement {
|
|
4394
4333
|
static properties = metadata.props;
|
|
4395
4334
|
render() {
|
|
@@ -4538,7 +4477,7 @@ var LitAdapter = class {
|
|
|
4538
4477
|
/**
|
|
4539
4478
|
* Render a component
|
|
4540
4479
|
*/
|
|
4541
|
-
render(component,
|
|
4480
|
+
render(component, _props) {
|
|
4542
4481
|
return component.render(this);
|
|
4543
4482
|
}
|
|
4544
4483
|
/**
|
|
@@ -4559,10 +4498,10 @@ var LitAdapter = class {
|
|
|
4559
4498
|
Promise.resolve().then(callback);
|
|
4560
4499
|
}
|
|
4561
4500
|
},
|
|
4562
|
-
computed: (
|
|
4501
|
+
computed: (_deps, compute) => {
|
|
4563
4502
|
return compute();
|
|
4564
4503
|
},
|
|
4565
|
-
memo: (value,
|
|
4504
|
+
memo: (value, _deps) => {
|
|
4566
4505
|
return value;
|
|
4567
4506
|
}
|
|
4568
4507
|
};
|
|
@@ -4574,7 +4513,7 @@ var LitAdapter = class {
|
|
|
4574
4513
|
this.element = element;
|
|
4575
4514
|
}
|
|
4576
4515
|
};
|
|
4577
|
-
function createLitComponent(descriptor, LitElement,
|
|
4516
|
+
function createLitComponent(descriptor, LitElement, _html) {
|
|
4578
4517
|
return class extends LitElement {
|
|
4579
4518
|
adapter = new LitAdapter(this);
|
|
4580
4519
|
connectedCallback() {
|
|
@@ -4710,7 +4649,7 @@ var VueAdapter = class {
|
|
|
4710
4649
|
* Get Vue-specific utilities
|
|
4711
4650
|
*/
|
|
4712
4651
|
getUtilities() {
|
|
4713
|
-
const { nextTick, computed
|
|
4652
|
+
const { nextTick, computed } = this.vue;
|
|
4714
4653
|
return {
|
|
4715
4654
|
batchUpdates: (callback) => {
|
|
4716
4655
|
callback();
|
|
@@ -4718,17 +4657,17 @@ var VueAdapter = class {
|
|
|
4718
4657
|
nextTick: (callback) => {
|
|
4719
4658
|
nextTick(callback);
|
|
4720
4659
|
},
|
|
4721
|
-
computed: (
|
|
4660
|
+
computed: (_deps, compute) => {
|
|
4722
4661
|
return computed(compute).value;
|
|
4723
4662
|
},
|
|
4724
|
-
memo: (value,
|
|
4663
|
+
memo: (value, _deps) => {
|
|
4725
4664
|
return value;
|
|
4726
4665
|
}
|
|
4727
4666
|
};
|
|
4728
4667
|
}
|
|
4729
4668
|
};
|
|
4730
4669
|
function createVueComponent(descriptor, vue) {
|
|
4731
|
-
const { defineComponent: defineComponent2
|
|
4670
|
+
const { defineComponent: defineComponent2 } = vue;
|
|
4732
4671
|
return defineComponent2({
|
|
4733
4672
|
name: descriptor.name,
|
|
4734
4673
|
props: descriptor.props || {},
|
|
@@ -4750,11 +4689,8 @@ var SvelteAdapter = class {
|
|
|
4750
4689
|
name = "svelte";
|
|
4751
4690
|
svelte;
|
|
4752
4691
|
// Svelte imports
|
|
4753
|
-
|
|
4754
|
-
// Component instance
|
|
4755
|
-
constructor(svelte, component) {
|
|
4692
|
+
constructor(svelte, _component) {
|
|
4756
4693
|
this.svelte = svelte;
|
|
4757
|
-
this.component = component;
|
|
4758
4694
|
}
|
|
4759
4695
|
/**
|
|
4760
4696
|
* Create a stateful value using Svelte stores
|
|
@@ -4845,7 +4781,7 @@ var SvelteAdapter = class {
|
|
|
4845
4781
|
/**
|
|
4846
4782
|
* Render a component
|
|
4847
4783
|
*/
|
|
4848
|
-
render(component,
|
|
4784
|
+
render(component, _props) {
|
|
4849
4785
|
return component.render(this);
|
|
4850
4786
|
}
|
|
4851
4787
|
/**
|
|
@@ -4865,7 +4801,7 @@ var SvelteAdapter = class {
|
|
|
4865
4801
|
const derivedStore = derived(deps, compute);
|
|
4866
4802
|
return get(derivedStore);
|
|
4867
4803
|
},
|
|
4868
|
-
memo: (value,
|
|
4804
|
+
memo: (value, _deps) => {
|
|
4869
4805
|
return value;
|
|
4870
4806
|
}
|
|
4871
4807
|
};
|
|
@@ -4913,7 +4849,6 @@ var RealtimeMockupService = class {
|
|
|
4913
4849
|
logs = [];
|
|
4914
4850
|
lastError = null;
|
|
4915
4851
|
callbacks = {};
|
|
4916
|
-
lastBlobSentAt = 0;
|
|
4917
4852
|
// Per-request send timestamps keyed by requestId, for client-observed
|
|
4918
4853
|
// round-trip timing in the mockup_rendered log. Pruned to a small cap so an
|
|
4919
4854
|
// in-flight burst can't grow it unbounded.
|
|
@@ -5443,7 +5378,6 @@ var RealtimeMockupService = class {
|
|
|
5443
5378
|
});
|
|
5444
5379
|
this.ws.send(message);
|
|
5445
5380
|
this.recordRequestSent(requestId);
|
|
5446
|
-
this.lastBlobSentAt = Date.now();
|
|
5447
5381
|
console.log(`[WS] canvas_state(ref) SENT: placement="${placement}" v${this.lastSentVersion} req=${requestId} stateId=${stateId} at ${Date.now()}`);
|
|
5448
5382
|
this.addLog(`Sent canvas stateId "${stateId}" for "${placement}" (v${this.lastSentVersion}, req ${requestId})`, "sent");
|
|
5449
5383
|
this.callbacks.onBlobSent?.(placement);
|
|
@@ -5481,7 +5415,6 @@ var RealtimeMockupService = class {
|
|
|
5481
5415
|
this.ws.send(message);
|
|
5482
5416
|
this.recordRequestSent(requestId);
|
|
5483
5417
|
this.lastSentStateJson[placement] = stateJson;
|
|
5484
|
-
this.lastBlobSentAt = Date.now();
|
|
5485
5418
|
console.log(`[WS] canvas_state SENT: placement="${placement}" v${this.lastSentVersion} req=${requestId} (${(message.length / 1024).toFixed(1)}KB) at ${Date.now()}`);
|
|
5486
5419
|
this.addLog(`Sent canvas state for "${placement}" (${(message.length / 1024).toFixed(1)}KB, v${this.lastSentVersion}, req ${requestId})`, "sent");
|
|
5487
5420
|
this.callbacks.onBlobSent?.(placement);
|
|
@@ -5511,7 +5444,6 @@ ${versionToSend}
|
|
|
5511
5444
|
combined.set(imageBytes, headerBytes.length);
|
|
5512
5445
|
}
|
|
5513
5446
|
this.ws.send(combined.buffer);
|
|
5514
|
-
this.lastBlobSentAt = Date.now();
|
|
5515
5447
|
this.addLog(`Sent canvas blob for placement "${placement}" (${imageBytes.length} bytes, v${versionToSend})`, "sent");
|
|
5516
5448
|
if (notifyCallback) {
|
|
5517
5449
|
this.callbacks.onBlobSent?.(placement);
|
|
@@ -6170,13 +6102,43 @@ async function getProduct(idOrSlug, config) {
|
|
|
6170
6102
|
const raw = await res.json();
|
|
6171
6103
|
return validateProductLoose(raw);
|
|
6172
6104
|
}
|
|
6105
|
+
async function searchDesigns(query = "", options) {
|
|
6106
|
+
const f = getFetcher(options);
|
|
6107
|
+
const meilisearchHost = options?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
6108
|
+
const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "eee819b849798ad9091228c486ec05d0931e5292";
|
|
6109
|
+
const designsIndex = options?.meilisearch?.designsIndex || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX || "snowcone-designs";
|
|
6110
|
+
const headers = {
|
|
6111
|
+
"Content-Type": "application/json"
|
|
6112
|
+
};
|
|
6113
|
+
if (meilisearchApiKey) {
|
|
6114
|
+
headers["Authorization"] = `Bearer ${meilisearchApiKey}`;
|
|
6115
|
+
}
|
|
6116
|
+
const url = `${meilisearchHost}/indexes/${designsIndex}/search`;
|
|
6117
|
+
const res = await f(url, {
|
|
6118
|
+
method: "POST",
|
|
6119
|
+
headers,
|
|
6120
|
+
body: JSON.stringify({
|
|
6121
|
+
q: query,
|
|
6122
|
+
limit: options?.limit || 50,
|
|
6123
|
+
...options?.offset ? { offset: options.offset } : {},
|
|
6124
|
+
...options?.filter ? { filter: options.filter } : {}
|
|
6125
|
+
})
|
|
6126
|
+
});
|
|
6127
|
+
if (!res.ok) throw new Error(`searchDesigns failed: ${res.status}`);
|
|
6128
|
+
const data = await res.json();
|
|
6129
|
+
const items = data.hits || [];
|
|
6130
|
+
return { items, total: data.estimatedTotalHits || items.length };
|
|
6131
|
+
}
|
|
6173
6132
|
function createClient(config) {
|
|
6174
6133
|
const fetcher = getFetcher(config);
|
|
6175
6134
|
const mockupService = new MockupServiceImpl(config.mockup || {}, fetcher);
|
|
6176
6135
|
return {
|
|
6177
6136
|
catalog: {
|
|
6178
6137
|
listProducts: (overrides) => listProducts({ ...config, ...overrides }),
|
|
6179
|
-
getProduct: (idOrSlug, overrides) => getProduct(idOrSlug, { ...config, ...overrides })
|
|
6138
|
+
getProduct: (idOrSlug, overrides) => getProduct(idOrSlug, { ...config, ...overrides }),
|
|
6139
|
+
designs: {
|
|
6140
|
+
search: (query, options) => searchDesigns(query, { ...config, ...options })
|
|
6141
|
+
}
|
|
6180
6142
|
},
|
|
6181
6143
|
mockup: mockupService
|
|
6182
6144
|
};
|
|
@@ -6299,6 +6261,7 @@ function createClient(config) {
|
|
|
6299
6261
|
resolveMockupId,
|
|
6300
6262
|
resolveVariantId,
|
|
6301
6263
|
retryOperation,
|
|
6264
|
+
searchDesigns,
|
|
6302
6265
|
simulateCartOperation,
|
|
6303
6266
|
toCombinations,
|
|
6304
6267
|
toOptionAttributes,
|
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-
|
|
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-
|
|
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(
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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,
|
|
2546
|
+
render(component: ComponentDescriptor, _props: ComponentProps): any;
|
|
2549
2547
|
/**
|
|
2550
2548
|
* Get Svelte-specific utilities
|
|
2551
2549
|
*/
|
|
@@ -3099,20 +3097,75 @@ interface SdkConfig {
|
|
|
3099
3097
|
host?: string;
|
|
3100
3098
|
apiKey?: string;
|
|
3101
3099
|
index?: string;
|
|
3100
|
+
/** Public designs-catalog index (pre-made, remixable designs). */
|
|
3101
|
+
designsIndex?: string;
|
|
3102
3102
|
};
|
|
3103
3103
|
}
|
|
3104
|
+
/**
|
|
3105
|
+
* A pre-made design from the public designs catalog (loosely typed). Docs
|
|
3106
|
+
* carry mockup-URL COMPONENTS (productId + per-placement asset URLs +
|
|
3107
|
+
* variant), never assembled URLs — build render URLs via @snowcone-app/mockup-url
|
|
3108
|
+
* (or pass `design`/`asset` straight into the canvas/embed primitives).
|
|
3109
|
+
*/
|
|
3110
|
+
interface CatalogDesign {
|
|
3111
|
+
/** = pairingId (the catalog document id). */
|
|
3112
|
+
id: string;
|
|
3113
|
+
pairingId?: string;
|
|
3114
|
+
slug?: string | null;
|
|
3115
|
+
title?: string;
|
|
3116
|
+
description?: string | null;
|
|
3117
|
+
tags?: string[];
|
|
3118
|
+
occasion?: string | null;
|
|
3119
|
+
style?: string | null;
|
|
3120
|
+
/** Product short code — the mockup URL path segment. */
|
|
3121
|
+
productId?: string;
|
|
3122
|
+
variant?: string | null;
|
|
3123
|
+
/** Bare-asset render component (flattened full-canvas export). */
|
|
3124
|
+
asset?: string | null;
|
|
3125
|
+
/** Per-placement render components: placement KEY → image URL. */
|
|
3126
|
+
assets?: Record<string, string> | null;
|
|
3127
|
+
previewThumbnail?: string | null;
|
|
3128
|
+
minPriceCents?: number | null;
|
|
3129
|
+
license?: {
|
|
3130
|
+
remixable?: boolean;
|
|
3131
|
+
};
|
|
3132
|
+
firstParty?: boolean;
|
|
3133
|
+
/** RESERVED — always null today; future structured slot metadata. */
|
|
3134
|
+
slots?: unknown;
|
|
3135
|
+
[key: string]: unknown;
|
|
3136
|
+
}
|
|
3137
|
+
interface DesignsSearchResponse {
|
|
3138
|
+
items: CatalogDesign[];
|
|
3139
|
+
total: number;
|
|
3140
|
+
}
|
|
3141
|
+
interface SearchDesignsOptions extends Partial<SdkConfig> {
|
|
3142
|
+
limit?: number;
|
|
3143
|
+
offset?: number;
|
|
3144
|
+
/** Meilisearch filter, e.g. "occasion = 'christmas' AND style = 'watercolor'". */
|
|
3145
|
+
filter?: string;
|
|
3146
|
+
}
|
|
3104
3147
|
interface SnowconeClient {
|
|
3105
3148
|
catalog: {
|
|
3106
3149
|
listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3107
3150
|
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3151
|
+
designs: {
|
|
3152
|
+
search(query?: string, options?: SearchDesignsOptions): Promise<DesignsSearchResponse>;
|
|
3153
|
+
};
|
|
3108
3154
|
};
|
|
3109
3155
|
mockup: MockupService;
|
|
3110
3156
|
}
|
|
3111
3157
|
declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3112
3158
|
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3159
|
+
/**
|
|
3160
|
+
* Search the public pre-made designs catalog (first-party-curated, remixable
|
|
3161
|
+
* designs) so an integration never starts from a blank canvas. Returns
|
|
3162
|
+
* mockup-URL components per design — feed `assets` (or `asset`) into
|
|
3163
|
+
* @snowcone-app/mockup-url's builder or the canvas/embed primitives.
|
|
3164
|
+
*/
|
|
3165
|
+
declare function searchDesigns(query?: string, options?: SearchDesignsOptions): Promise<DesignsSearchResponse>;
|
|
3113
3166
|
/**
|
|
3114
3167
|
* Create a unified Snowcone client with catalog and mockup services
|
|
3115
3168
|
*/
|
|
3116
3169
|
declare function createClient(config: SdkConfig): SnowconeClient;
|
|
3117
3170
|
|
|
3118
|
-
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 };
|
|
3171
|
+
export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogDesign, type CatalogListResponse, type CatalogProduct, ClassNames, type ColorDesignElement, ColorPickerUtils, Combination, CommonProps, ComponentContext, type ComponentDefinition, ComponentDescriptor, ComponentEventManager, ComponentFactory, ComponentLifecycle, ComponentLifecycleHooks, type ComponentMetadata, ComponentProps, ComponentRegistry, ComponentState, type ComponentTemplate, ComponentTemplates, type ContainerDescriptor, ContextBridge, type ContextComparator, type ContextConsumer, ContextInjector, type ContextProviderConfig, type ContextSubscriber, ContextSynchronizer, type CreateDesignStateInput, type CreatedDesignState, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_BUY_BASE, DEFAULT_COLOR, DEFAULT_GRANT_BASE, DEFAULT_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type DesignsSearchResponse, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type 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 SearchDesignsOptions, 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, searchDesigns, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,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-
|
|
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-
|
|
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(
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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,
|
|
2546
|
+
render(component: ComponentDescriptor, _props: ComponentProps): any;
|
|
2549
2547
|
/**
|
|
2550
2548
|
* Get Svelte-specific utilities
|
|
2551
2549
|
*/
|
|
@@ -3099,20 +3097,75 @@ interface SdkConfig {
|
|
|
3099
3097
|
host?: string;
|
|
3100
3098
|
apiKey?: string;
|
|
3101
3099
|
index?: string;
|
|
3100
|
+
/** Public designs-catalog index (pre-made, remixable designs). */
|
|
3101
|
+
designsIndex?: string;
|
|
3102
3102
|
};
|
|
3103
3103
|
}
|
|
3104
|
+
/**
|
|
3105
|
+
* A pre-made design from the public designs catalog (loosely typed). Docs
|
|
3106
|
+
* carry mockup-URL COMPONENTS (productId + per-placement asset URLs +
|
|
3107
|
+
* variant), never assembled URLs — build render URLs via @snowcone-app/mockup-url
|
|
3108
|
+
* (or pass `design`/`asset` straight into the canvas/embed primitives).
|
|
3109
|
+
*/
|
|
3110
|
+
interface CatalogDesign {
|
|
3111
|
+
/** = pairingId (the catalog document id). */
|
|
3112
|
+
id: string;
|
|
3113
|
+
pairingId?: string;
|
|
3114
|
+
slug?: string | null;
|
|
3115
|
+
title?: string;
|
|
3116
|
+
description?: string | null;
|
|
3117
|
+
tags?: string[];
|
|
3118
|
+
occasion?: string | null;
|
|
3119
|
+
style?: string | null;
|
|
3120
|
+
/** Product short code — the mockup URL path segment. */
|
|
3121
|
+
productId?: string;
|
|
3122
|
+
variant?: string | null;
|
|
3123
|
+
/** Bare-asset render component (flattened full-canvas export). */
|
|
3124
|
+
asset?: string | null;
|
|
3125
|
+
/** Per-placement render components: placement KEY → image URL. */
|
|
3126
|
+
assets?: Record<string, string> | null;
|
|
3127
|
+
previewThumbnail?: string | null;
|
|
3128
|
+
minPriceCents?: number | null;
|
|
3129
|
+
license?: {
|
|
3130
|
+
remixable?: boolean;
|
|
3131
|
+
};
|
|
3132
|
+
firstParty?: boolean;
|
|
3133
|
+
/** RESERVED — always null today; future structured slot metadata. */
|
|
3134
|
+
slots?: unknown;
|
|
3135
|
+
[key: string]: unknown;
|
|
3136
|
+
}
|
|
3137
|
+
interface DesignsSearchResponse {
|
|
3138
|
+
items: CatalogDesign[];
|
|
3139
|
+
total: number;
|
|
3140
|
+
}
|
|
3141
|
+
interface SearchDesignsOptions extends Partial<SdkConfig> {
|
|
3142
|
+
limit?: number;
|
|
3143
|
+
offset?: number;
|
|
3144
|
+
/** Meilisearch filter, e.g. "occasion = 'christmas' AND style = 'watercolor'". */
|
|
3145
|
+
filter?: string;
|
|
3146
|
+
}
|
|
3104
3147
|
interface SnowconeClient {
|
|
3105
3148
|
catalog: {
|
|
3106
3149
|
listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3107
3150
|
getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3151
|
+
designs: {
|
|
3152
|
+
search(query?: string, options?: SearchDesignsOptions): Promise<DesignsSearchResponse>;
|
|
3153
|
+
};
|
|
3108
3154
|
};
|
|
3109
3155
|
mockup: MockupService;
|
|
3110
3156
|
}
|
|
3111
3157
|
declare function listProducts(config?: Partial<SdkConfig>): Promise<CatalogListResponse>;
|
|
3112
3158
|
declare function getProduct(idOrSlug: string, config?: Partial<SdkConfig>): Promise<CatalogProduct>;
|
|
3159
|
+
/**
|
|
3160
|
+
* Search the public pre-made designs catalog (first-party-curated, remixable
|
|
3161
|
+
* designs) so an integration never starts from a blank canvas. Returns
|
|
3162
|
+
* mockup-URL components per design — feed `assets` (or `asset`) into
|
|
3163
|
+
* @snowcone-app/mockup-url's builder or the canvas/embed primitives.
|
|
3164
|
+
*/
|
|
3165
|
+
declare function searchDesigns(query?: string, options?: SearchDesignsOptions): Promise<DesignsSearchResponse>;
|
|
3113
3166
|
/**
|
|
3114
3167
|
* Create a unified Snowcone client with catalog and mockup services
|
|
3115
3168
|
*/
|
|
3116
3169
|
declare function createClient(config: SdkConfig): SnowconeClient;
|
|
3117
3170
|
|
|
3118
|
-
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 };
|
|
3171
|
+
export { AbstractTemplateRenderer, type AddToCartOptions, Animations, type ArtSelectorContext, type ArtSelectorDescriptor, type ArtSelectorOptions, type ArtworkData, type AspectRatio, Attributes, type BaseDescriptor, type BlendConfig, type BuildMockupUrlConfig, type CartDetail, type CatalogDesign, type CatalogListResponse, type CatalogProduct, ClassNames, type ColorDesignElement, ColorPickerUtils, Combination, CommonProps, ComponentContext, type ComponentDefinition, ComponentDescriptor, ComponentEventManager, ComponentFactory, ComponentLifecycle, ComponentLifecycleHooks, type ComponentMetadata, ComponentProps, ComponentRegistry, ComponentState, type ComponentTemplate, ComponentTemplates, type ContainerDescriptor, ContextBridge, type ContextComparator, type ContextConsumer, ContextInjector, type ContextProviderConfig, type ContextSubscriber, ContextSynchronizer, type CreateDesignStateInput, type CreatedDesignState, DEFAULT_ARTWORK_URL, DEFAULT_ASPECT_RATIO, DEFAULT_BUY_BASE, DEFAULT_COLOR, DEFAULT_GRANT_BASE, DEFAULT_MOCKUP_BASE, DEFAULT_PLACEMENT_DIMENSIONS, type Descriptor, type Design, type DesignElement, type DesignGenerationContext, type DesignLike, type DesignsSearchResponse, type Effects, Elements, type ErrorContext, type ErrorHandler, ErrorManager, type EventDefinition, EventDelegator, EventEmitter, EventHandler, type EventListener, type EventPayload, type 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 SearchDesignsOptions, 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, searchDesigns, simulateCartOperation, toCombinations, toOptionAttributes, useFrameworkAdapter as useVueAdapter, validateAlignment, validateDesignElement, validateEffects, validateImageUrl, validateMockupOptions, validateProductSelection, validateProductSpec, validateRequiredOptions, validateTileCount, warnVariantNotSelected, withContext, withErrorHandling, withSyncErrorHandling };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
REALTIME_WS_URL,
|
|
6
6
|
RealtimeMockupService
|
|
7
|
-
} from "./chunk-
|
|
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: (
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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,
|
|
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: (
|
|
4134
|
+
computed: (_deps, compute) => {
|
|
4197
4135
|
return compute();
|
|
4198
4136
|
},
|
|
4199
|
-
memo: (value,
|
|
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,
|
|
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
|
|
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: (
|
|
4293
|
+
computed: (_deps, compute) => {
|
|
4356
4294
|
return computed(compute).value;
|
|
4357
4295
|
},
|
|
4358
|
-
memo: (value,
|
|
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
|
|
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
|
-
|
|
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,
|
|
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,
|
|
4437
|
+
memo: (value, _deps) => {
|
|
4503
4438
|
return value;
|
|
4504
4439
|
}
|
|
4505
4440
|
};
|
|
@@ -5042,13 +4977,43 @@ async function getProduct(idOrSlug, config) {
|
|
|
5042
4977
|
const raw = await res.json();
|
|
5043
4978
|
return validateProductLoose(raw);
|
|
5044
4979
|
}
|
|
4980
|
+
async function searchDesigns(query = "", options) {
|
|
4981
|
+
const f = getFetcher(options);
|
|
4982
|
+
const meilisearchHost = options?.meilisearch?.host || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_HOST || "https://search.snowcone.app";
|
|
4983
|
+
const meilisearchApiKey = options?.meilisearch?.apiKey || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_API_KEY || "eee819b849798ad9091228c486ec05d0931e5292";
|
|
4984
|
+
const designsIndex = options?.meilisearch?.designsIndex || typeof process !== "undefined" && process.env?.NEXT_PUBLIC_MEILISEARCH_DESIGNS_INDEX || "snowcone-designs";
|
|
4985
|
+
const headers = {
|
|
4986
|
+
"Content-Type": "application/json"
|
|
4987
|
+
};
|
|
4988
|
+
if (meilisearchApiKey) {
|
|
4989
|
+
headers["Authorization"] = `Bearer ${meilisearchApiKey}`;
|
|
4990
|
+
}
|
|
4991
|
+
const url = `${meilisearchHost}/indexes/${designsIndex}/search`;
|
|
4992
|
+
const res = await f(url, {
|
|
4993
|
+
method: "POST",
|
|
4994
|
+
headers,
|
|
4995
|
+
body: JSON.stringify({
|
|
4996
|
+
q: query,
|
|
4997
|
+
limit: options?.limit || 50,
|
|
4998
|
+
...options?.offset ? { offset: options.offset } : {},
|
|
4999
|
+
...options?.filter ? { filter: options.filter } : {}
|
|
5000
|
+
})
|
|
5001
|
+
});
|
|
5002
|
+
if (!res.ok) throw new Error(`searchDesigns failed: ${res.status}`);
|
|
5003
|
+
const data = await res.json();
|
|
5004
|
+
const items = data.hits || [];
|
|
5005
|
+
return { items, total: data.estimatedTotalHits || items.length };
|
|
5006
|
+
}
|
|
5045
5007
|
function createClient(config) {
|
|
5046
5008
|
const fetcher = getFetcher(config);
|
|
5047
5009
|
const mockupService = new MockupServiceImpl(config.mockup || {}, fetcher);
|
|
5048
5010
|
return {
|
|
5049
5011
|
catalog: {
|
|
5050
5012
|
listProducts: (overrides) => listProducts({ ...config, ...overrides }),
|
|
5051
|
-
getProduct: (idOrSlug, overrides) => getProduct(idOrSlug, { ...config, ...overrides })
|
|
5013
|
+
getProduct: (idOrSlug, overrides) => getProduct(idOrSlug, { ...config, ...overrides }),
|
|
5014
|
+
designs: {
|
|
5015
|
+
search: (query, options) => searchDesigns(query, { ...config, ...options })
|
|
5016
|
+
}
|
|
5052
5017
|
},
|
|
5053
5018
|
mockup: mockupService
|
|
5054
5019
|
};
|
|
@@ -5170,6 +5135,7 @@ export {
|
|
|
5170
5135
|
resolveMockupId,
|
|
5171
5136
|
resolveVariantId,
|
|
5172
5137
|
retryOperation,
|
|
5138
|
+
searchDesigns,
|
|
5173
5139
|
simulateCartOperation,
|
|
5174
5140
|
toCombinations,
|
|
5175
5141
|
toOptionAttributes,
|
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-
|
|
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-
|
|
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