@snowcone-app/ui 0.4.7 → 0.4.8
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 +9 -0
- package/dist/index.cjs +282 -272
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -45
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/patterns/RealtimeProvider.tsx +13 -1
package/dist/index.js
CHANGED
|
@@ -5549,8 +5549,8 @@ import { useRef as useRef13, useEffect as useEffect18, useMemo as useMemo8, useS
|
|
|
5549
5549
|
|
|
5550
5550
|
// src/patterns/RealtimeProvider.tsx
|
|
5551
5551
|
import {
|
|
5552
|
-
createContext as
|
|
5553
|
-
useContext as
|
|
5552
|
+
createContext as createContext8,
|
|
5553
|
+
useContext as useContext6,
|
|
5554
5554
|
useState as useState17,
|
|
5555
5555
|
useEffect as useEffect17,
|
|
5556
5556
|
useCallback as useCallback10,
|
|
@@ -5559,10 +5559,23 @@ import {
|
|
|
5559
5559
|
} from "react";
|
|
5560
5560
|
import { useRealtimeMockup as useRealtimeMockup2 } from "@snowcone-app/sdk/react";
|
|
5561
5561
|
import { resolveVariantId as resolveVariantIdUtil } from "@snowcone-app/sdk";
|
|
5562
|
+
|
|
5563
|
+
// src/patterns/MockupBackground.tsx
|
|
5564
|
+
import { createContext as createContext7, useContext as useContext5 } from "react";
|
|
5562
5565
|
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
5566
|
+
var MockupBackgroundContext = createContext7(void 0);
|
|
5567
|
+
function MockupBackground({ bg, children }) {
|
|
5568
|
+
return /* @__PURE__ */ jsx51(MockupBackgroundContext.Provider, { value: bg, children });
|
|
5569
|
+
}
|
|
5570
|
+
function useMockupBackgroundOptional() {
|
|
5571
|
+
return useContext5(MockupBackgroundContext);
|
|
5572
|
+
}
|
|
5573
|
+
|
|
5574
|
+
// src/patterns/RealtimeProvider.tsx
|
|
5575
|
+
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
5563
5576
|
var DEFAULT_ARTBOARD_SIZE = 2e3;
|
|
5564
5577
|
var MAX_CONCURRENT_BLOBS = 5;
|
|
5565
|
-
var RealtimeContext =
|
|
5578
|
+
var RealtimeContext = createContext8(
|
|
5566
5579
|
void 0
|
|
5567
5580
|
);
|
|
5568
5581
|
function RealtimeProvider({
|
|
@@ -5576,6 +5589,7 @@ function RealtimeProvider({
|
|
|
5576
5589
|
grantUrl
|
|
5577
5590
|
}) {
|
|
5578
5591
|
const productContext = useProductOptional();
|
|
5592
|
+
const mockupBg = useMockupBackgroundOptional();
|
|
5579
5593
|
const [isEnabled, setIsEnabled] = useState17(autoEnable);
|
|
5580
5594
|
const useSessionGrant = Boolean(shop && grantUrl);
|
|
5581
5595
|
const getToken = useCallback10(async () => {
|
|
@@ -5596,6 +5610,7 @@ function RealtimeProvider({
|
|
|
5596
5610
|
const configSentRef = useRef12(false);
|
|
5597
5611
|
const placementSettingsOverridesRef = useRef12({});
|
|
5598
5612
|
const lastSentVariantIdRef = useRef12(null);
|
|
5613
|
+
const lastSentBgRef = useRef12(void 0);
|
|
5599
5614
|
const lastSentColorsRef = useRef12({});
|
|
5600
5615
|
const realtimeMockup = useRealtimeMockup2({
|
|
5601
5616
|
wsUrl,
|
|
@@ -5781,6 +5796,7 @@ function RealtimeProvider({
|
|
|
5781
5796
|
disconnect();
|
|
5782
5797
|
configSentRef.current = false;
|
|
5783
5798
|
lastSentVariantIdRef.current = null;
|
|
5799
|
+
lastSentBgRef.current = void 0;
|
|
5784
5800
|
lastSentColorsRef.current = {};
|
|
5785
5801
|
};
|
|
5786
5802
|
}
|
|
@@ -5802,7 +5818,8 @@ function RealtimeProvider({
|
|
|
5802
5818
|
);
|
|
5803
5819
|
const isFirstSend = !configSentRef.current;
|
|
5804
5820
|
const variantChanged = lastSentVariantIdRef.current !== null && lastSentVariantIdRef.current !== variantId;
|
|
5805
|
-
|
|
5821
|
+
const bgChanged = configSentRef.current && lastSentBgRef.current !== mockupBg;
|
|
5822
|
+
if (!isFirstSend && !variantChanged && !bgChanged) {
|
|
5806
5823
|
return;
|
|
5807
5824
|
}
|
|
5808
5825
|
const mockupIds = [];
|
|
@@ -5819,6 +5836,7 @@ function RealtimeProvider({
|
|
|
5819
5836
|
variantId,
|
|
5820
5837
|
shop,
|
|
5821
5838
|
width: mockupWidth,
|
|
5839
|
+
...mockupBg ? { bg: mockupBg } : {},
|
|
5822
5840
|
placementSettings: { ...placementSettingsOverridesRef.current }
|
|
5823
5841
|
} : {
|
|
5824
5842
|
productId,
|
|
@@ -5827,6 +5845,7 @@ function RealtimeProvider({
|
|
|
5827
5845
|
shop: "hTidnpNnNa",
|
|
5828
5846
|
seal: "bypass-sig-for-k6-load-test",
|
|
5829
5847
|
width: mockupWidth,
|
|
5848
|
+
...mockupBg ? { bg: mockupBg } : {},
|
|
5830
5849
|
placementSettings: { ...placementSettingsOverridesRef.current }
|
|
5831
5850
|
};
|
|
5832
5851
|
if (variantChanged) {
|
|
@@ -5838,6 +5857,7 @@ function RealtimeProvider({
|
|
|
5838
5857
|
sendConfigRaw(configPayload);
|
|
5839
5858
|
configSentRef.current = true;
|
|
5840
5859
|
lastSentVariantIdRef.current = variantId;
|
|
5860
|
+
lastSentBgRef.current = mockupBg;
|
|
5841
5861
|
setTimeout(() => {
|
|
5842
5862
|
const colorPlacements = placements.filter((p) => p.type === "color");
|
|
5843
5863
|
colorPlacements.forEach((p) => {
|
|
@@ -5855,7 +5875,8 @@ function RealtimeProvider({
|
|
|
5855
5875
|
productContext?.selection,
|
|
5856
5876
|
sendConfigRaw,
|
|
5857
5877
|
sendColorBlobTracked,
|
|
5858
|
-
mockupWidth
|
|
5878
|
+
mockupWidth,
|
|
5879
|
+
mockupBg
|
|
5859
5880
|
]);
|
|
5860
5881
|
useEffect17(() => {
|
|
5861
5882
|
if (!isEnabled || !isConnected || !isConfigured || !productContext?.product)
|
|
@@ -6223,17 +6244,17 @@ function RealtimeProvider({
|
|
|
6223
6244
|
registerBlobUrl
|
|
6224
6245
|
]
|
|
6225
6246
|
);
|
|
6226
|
-
return /* @__PURE__ */
|
|
6247
|
+
return /* @__PURE__ */ jsx52(RealtimeContext.Provider, { value: contextValue, children });
|
|
6227
6248
|
}
|
|
6228
6249
|
function useRealtime() {
|
|
6229
|
-
const context =
|
|
6250
|
+
const context = useContext6(RealtimeContext);
|
|
6230
6251
|
if (!context) {
|
|
6231
6252
|
throw new Error("useRealtime must be used within a RealtimeProvider");
|
|
6232
6253
|
}
|
|
6233
6254
|
return context;
|
|
6234
6255
|
}
|
|
6235
6256
|
function useRealtimeOptional() {
|
|
6236
|
-
return
|
|
6257
|
+
return useContext6(RealtimeContext);
|
|
6237
6258
|
}
|
|
6238
6259
|
|
|
6239
6260
|
// src/hooks/useCanvasContext.ts
|
|
@@ -7043,19 +7064,19 @@ import { useCallback as useCallback15, useMemo as useMemo10 } from "react";
|
|
|
7043
7064
|
|
|
7044
7065
|
// src/patterns/MockupPriorityProvider.tsx
|
|
7045
7066
|
import {
|
|
7046
|
-
createContext as
|
|
7047
|
-
useContext as
|
|
7067
|
+
createContext as createContext9,
|
|
7068
|
+
useContext as useContext7,
|
|
7048
7069
|
useCallback as useCallback14,
|
|
7049
7070
|
useRef as useRef18,
|
|
7050
7071
|
useMemo as useMemo9,
|
|
7051
7072
|
useState as useState23,
|
|
7052
7073
|
useEffect as useEffect23
|
|
7053
7074
|
} from "react";
|
|
7054
|
-
import { jsx as
|
|
7075
|
+
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
7055
7076
|
var MAX_LEVEL3_PREFETCH = 5;
|
|
7056
7077
|
var PRIORITY_RECALC_DEBOUNCE_MS = 50;
|
|
7057
7078
|
var PRELOAD_MARGIN_PX = 750;
|
|
7058
|
-
var MockupPriorityContext =
|
|
7079
|
+
var MockupPriorityContext = createContext9(
|
|
7059
7080
|
void 0
|
|
7060
7081
|
);
|
|
7061
7082
|
function MockupPriorityProvider({ children }) {
|
|
@@ -7635,10 +7656,10 @@ function MockupPriorityProvider({ children }) {
|
|
|
7635
7656
|
subscribeLevel1Change
|
|
7636
7657
|
]
|
|
7637
7658
|
);
|
|
7638
|
-
return /* @__PURE__ */
|
|
7659
|
+
return /* @__PURE__ */ jsx53(MockupPriorityContext.Provider, { value: contextValue, children });
|
|
7639
7660
|
}
|
|
7640
7661
|
function useMockupPriority() {
|
|
7641
|
-
const context =
|
|
7662
|
+
const context = useContext7(MockupPriorityContext);
|
|
7642
7663
|
if (!context) {
|
|
7643
7664
|
throw new Error(
|
|
7644
7665
|
"useMockupPriority must be used within a MockupPriorityProvider"
|
|
@@ -7647,7 +7668,7 @@ function useMockupPriority() {
|
|
|
7647
7668
|
return context;
|
|
7648
7669
|
}
|
|
7649
7670
|
function useMockupPriorityOptional() {
|
|
7650
|
-
return
|
|
7671
|
+
return useContext7(MockupPriorityContext);
|
|
7651
7672
|
}
|
|
7652
7673
|
|
|
7653
7674
|
// src/hooks/useProductPage.ts
|
|
@@ -8373,8 +8394,8 @@ var CanvasExportService = class _CanvasExportService {
|
|
|
8373
8394
|
var canvasExportService = new CanvasExportService();
|
|
8374
8395
|
|
|
8375
8396
|
// src/components/CanvasIsolationBoundary.tsx
|
|
8376
|
-
import
|
|
8377
|
-
import { Fragment as Fragment9, jsx as
|
|
8397
|
+
import React41, { useEffect as useEffect26 } from "react";
|
|
8398
|
+
import { Fragment as Fragment9, jsx as jsx54, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
8378
8399
|
function CanvasIsolationConfigurator({
|
|
8379
8400
|
placementName: placementNameProp,
|
|
8380
8401
|
onArtworkChange,
|
|
@@ -8421,9 +8442,9 @@ function CanvasIsolationConfigurator({
|
|
|
8421
8442
|
}, []);
|
|
8422
8443
|
return null;
|
|
8423
8444
|
}
|
|
8424
|
-
var IsolatedChildren =
|
|
8445
|
+
var IsolatedChildren = React41.memo(
|
|
8425
8446
|
function IsolatedChildren2({ children }) {
|
|
8426
|
-
return /* @__PURE__ */
|
|
8447
|
+
return /* @__PURE__ */ jsx54(Fragment9, { children });
|
|
8427
8448
|
},
|
|
8428
8449
|
// Custom comparison: ALWAYS return true (never re-render due to parent changes)
|
|
8429
8450
|
// This is intentional - children should use refs/services for updates that need to bypass this
|
|
@@ -8437,7 +8458,7 @@ function CanvasIsolationBoundary({
|
|
|
8437
8458
|
serializeStateForServer
|
|
8438
8459
|
}) {
|
|
8439
8460
|
return /* @__PURE__ */ jsxs33(Fragment9, { children: [
|
|
8440
|
-
/* @__PURE__ */
|
|
8461
|
+
/* @__PURE__ */ jsx54(
|
|
8441
8462
|
CanvasIsolationConfigurator,
|
|
8442
8463
|
{
|
|
8443
8464
|
placementName,
|
|
@@ -8446,7 +8467,7 @@ function CanvasIsolationBoundary({
|
|
|
8446
8467
|
serializeStateForServer
|
|
8447
8468
|
}
|
|
8448
8469
|
),
|
|
8449
|
-
/* @__PURE__ */
|
|
8470
|
+
/* @__PURE__ */ jsx54(IsolatedChildren, { children })
|
|
8450
8471
|
] });
|
|
8451
8472
|
}
|
|
8452
8473
|
function useIsolatedCanvas() {
|
|
@@ -8470,7 +8491,7 @@ function useIsolatedCanvas() {
|
|
|
8470
8491
|
|
|
8471
8492
|
// src/components/LoadingOverlayPrism.tsx
|
|
8472
8493
|
import { useState as useState26, useEffect as useEffect27, useCallback as useCallback16, useRef as useRef19 } from "react";
|
|
8473
|
-
import { jsx as
|
|
8494
|
+
import { jsx as jsx55, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
8474
8495
|
function generateParticles() {
|
|
8475
8496
|
return Array.from({ length: 16 }, () => ({
|
|
8476
8497
|
left: 10 + Math.random() * 80,
|
|
@@ -8614,13 +8635,13 @@ function LoadingOverlayPrism({
|
|
|
8614
8635
|
onTransitionEnd: handleTransitionEnd,
|
|
8615
8636
|
children: [
|
|
8616
8637
|
/* @__PURE__ */ jsxs34("div", { className: "prism-loading-rainbow", children: [
|
|
8617
|
-
/* @__PURE__ */
|
|
8618
|
-
/* @__PURE__ */
|
|
8619
|
-
/* @__PURE__ */
|
|
8620
|
-
/* @__PURE__ */
|
|
8621
|
-
/* @__PURE__ */
|
|
8638
|
+
/* @__PURE__ */ jsx55("div", { className: "prism-loading-band" }),
|
|
8639
|
+
/* @__PURE__ */ jsx55("div", { className: "prism-loading-band" }),
|
|
8640
|
+
/* @__PURE__ */ jsx55("div", { className: "prism-loading-band" }),
|
|
8641
|
+
/* @__PURE__ */ jsx55("div", { className: "prism-loading-band" }),
|
|
8642
|
+
/* @__PURE__ */ jsx55("div", { className: "prism-loading-band" })
|
|
8622
8643
|
] }),
|
|
8623
|
-
particles.map((p, i) => /* @__PURE__ */
|
|
8644
|
+
particles.map((p, i) => /* @__PURE__ */ jsx55(
|
|
8624
8645
|
"div",
|
|
8625
8646
|
{
|
|
8626
8647
|
className: "prism-loading-particle",
|
|
@@ -8682,7 +8703,7 @@ import {
|
|
|
8682
8703
|
useCallback as useCallback17
|
|
8683
8704
|
} from "react";
|
|
8684
8705
|
import { createPortal as createPortal2 } from "react-dom";
|
|
8685
|
-
import { Fragment as Fragment10, jsx as
|
|
8706
|
+
import { Fragment as Fragment10, jsx as jsx56, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
8686
8707
|
var BANDS = [
|
|
8687
8708
|
{ rgb: "230, 45, 55", delay: "-0.0s" },
|
|
8688
8709
|
// red
|
|
@@ -8863,8 +8884,8 @@ function CandyVisual({
|
|
|
8863
8884
|
style,
|
|
8864
8885
|
onTransitionEnd,
|
|
8865
8886
|
children: [
|
|
8866
|
-
BANDS.map((_, i) => /* @__PURE__ */
|
|
8867
|
-
particles.map((p, i) => /* @__PURE__ */
|
|
8887
|
+
BANDS.map((_, i) => /* @__PURE__ */ jsx56("div", { className: "candy-band" }, `b-${i}`)),
|
|
8888
|
+
particles.map((p, i) => /* @__PURE__ */ jsx56(
|
|
8868
8889
|
"div",
|
|
8869
8890
|
{
|
|
8870
8891
|
className: "candy-particle",
|
|
@@ -8930,7 +8951,7 @@ var LoadingOverlayPrismCandy = memo2(function LoadingOverlayPrismCandy2({
|
|
|
8930
8951
|
if (!visible) fadeClass = "candy-fade-out";
|
|
8931
8952
|
else if (mounted) fadeClass = "candy-fade-in";
|
|
8932
8953
|
return /* @__PURE__ */ jsxs35(Fragment10, { children: [
|
|
8933
|
-
/* @__PURE__ */
|
|
8954
|
+
/* @__PURE__ */ jsx56(
|
|
8934
8955
|
"div",
|
|
8935
8956
|
{
|
|
8936
8957
|
ref: anchorRef,
|
|
@@ -8943,7 +8964,7 @@ var LoadingOverlayPrismCandy = memo2(function LoadingOverlayPrismCandy2({
|
|
|
8943
8964
|
}
|
|
8944
8965
|
),
|
|
8945
8966
|
bounds && typeof document !== "undefined" && createPortal2(
|
|
8946
|
-
/* @__PURE__ */
|
|
8967
|
+
/* @__PURE__ */ jsx56(
|
|
8947
8968
|
CandyVisual,
|
|
8948
8969
|
{
|
|
8949
8970
|
fadeClass,
|
|
@@ -8984,7 +9005,7 @@ var LoadingOverlayPrismCandyInline = memo2(
|
|
|
8984
9005
|
let fadeClass = "";
|
|
8985
9006
|
if (!visible) fadeClass = "candy-fade-out";
|
|
8986
9007
|
else if (mounted) fadeClass = "candy-fade-in";
|
|
8987
|
-
return /* @__PURE__ */
|
|
9008
|
+
return /* @__PURE__ */ jsx56(
|
|
8988
9009
|
CandyVisual,
|
|
8989
9010
|
{
|
|
8990
9011
|
fadeClass,
|
|
@@ -9004,17 +9025,6 @@ var LoadingOverlayPrismCandyInline = memo2(
|
|
|
9004
9025
|
import { useRealtimeMockup as useRealtimeMockup3 } from "@snowcone-app/sdk/react";
|
|
9005
9026
|
import { getProduct as getProduct3, listProducts as listProducts4, getMockupUrl as getMockupUrl2 } from "@snowcone-app/sdk";
|
|
9006
9027
|
|
|
9007
|
-
// src/patterns/MockupBackground.tsx
|
|
9008
|
-
import { createContext as createContext9, useContext as useContext7 } from "react";
|
|
9009
|
-
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
9010
|
-
var MockupBackgroundContext = createContext9(void 0);
|
|
9011
|
-
function MockupBackground({ bg, children }) {
|
|
9012
|
-
return /* @__PURE__ */ jsx56(MockupBackgroundContext.Provider, { value: bg, children });
|
|
9013
|
-
}
|
|
9014
|
-
function useMockupBackgroundOptional() {
|
|
9015
|
-
return useContext7(MockupBackgroundContext);
|
|
9016
|
-
}
|
|
9017
|
-
|
|
9018
9028
|
// src/patterns/ProductPageProvider.tsx
|
|
9019
9029
|
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
9020
9030
|
function ProductPageProvider({
|