@replohq/canopy-sdk 0.20.0 → 1.0.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/_vendor/replo-utils/lib/crypto.d.ts +30 -0
- package/_vendor/replo-utils/lib/errors.d.ts +83 -0
- package/_vendor/replo-utils/lib/json.mjs +1 -1
- package/_vendor/replo-utils/lib/misc.mjs +2 -2
- package/_vendor/schemas/errors.d.ts +438 -0
- package/_vendor/schemas/generated/errors.d.ts +61 -0
- package/_vendor/schemas/money.d.ts +55 -0
- package/_vendor/schemas/money.mjs +193 -0
- package/_vendor/schemas/selectMode.mjs +2 -2
- package/analytics/analytics-sink.d.ts +6 -0
- package/cart/cart-provider.js +18 -4
- package/cart/cart-provider.js.map +2 -2
- package/cart/cart-types.d.ts +2 -0
- package/cart/cart-types.js.map +2 -2
- package/cart/gateways/cart-constants.d.ts +1 -1
- package/cart/gateways/cart-constants.js +1 -1
- package/cart/gateways/cart-constants.js.map +2 -2
- package/cart/gateways/default-cart-gateway.js +1 -1
- package/cart/gateways/default-cart-gateway.js.map +2 -2
- package/cart/hooks/use-add-to-cart.js +6 -2
- package/cart/hooks/use-add-to-cart.js.map +2 -2
- package/cart/utils/cart-utils.d.ts +0 -4
- package/cart/utils/cart-utils.js +0 -8
- package/cart/utils/cart-utils.js.map +2 -2
- package/cart/utils/variant-to-cart-line.js +22 -5
- package/cart/utils/variant-to-cart-line.js.map +2 -2
- package/{chunk-ME5W2TJM.mjs → chunk-UWHM3FKU.mjs} +1 -1
- package/editor/DocumentReadyBeacon.d.ts +1 -1
- package/editor/DocumentReadyBeacon.js +0 -3
- package/editor/DocumentReadyBeacon.js.map +2 -2
- package/editor/NextErrorReporter.js +8 -5
- package/editor/NextErrorReporter.js.map +2 -2
- package/hooks/use-formatted-price.d.ts +1 -1
- package/hooks/use-formatted-price.js +7 -6
- package/hooks/use-formatted-price.js.map +2 -2
- package/money.d.ts +9 -0
- package/money.js +13 -0
- package/money.js.map +7 -0
- package/package.json +2 -1
- package/providers/replo-provider.js +5 -4
- package/providers/replo-provider.js.map +2 -2
- package/{chunk-NCKKAFF7.mjs → chunk-ILGEM42C.mjs} +7 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../cart/utils/cart-utils.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Cart, CartLine } from \"../cart-types\";\n\nimport { getCartLinePricing } from \"./variant-to-cart-line\";\n\nexport interface CartTotals {\n subtotal: number;\n discountAmount: number;\n totalSavings: number;\n total: number;\n}\n\n/**\n * Sum the final (post selling-plan) price of every line item in the cart.\n * This is the authoritative subtotal for cookie-based carts, which have no\n * server-computed cost to rely on.\n */\nexport function calculateLineItemsSubtotal(lineItems: CartLine[]): number {\n return lineItems.reduce(\n (sum, item) => sum + getCartLinePricing(item).finalPrice * item.quantity,\n 0,\n );\n}\n\n/**\n * Calculate cart totals including subtotal, discounts, and final total.\n * When cart cost data is provided (from Shopify), uses the actual totalAmount\n * which includes cart-level discounts from discount codes.\n *\n * @param options - Object containing lineItems and cart\n * @param options.lineItems - Array of cart line items\n * @param options.cart - Optional cart data from Shopify (includes discount codes)\n */\nexport function calculateCartTotals({\n lineItems,\n cart,\n}: {\n lineItems: CartLine[];\n cart: Cart | null;\n}): CartTotals {\n const lineItemSubtotal = calculateLineItemsSubtotal(lineItems);\n const compareAtSubtotal = lineItems.reduce((sum, item) => {\n return sum + getCartLinePricing(item).compareAtPrice * item.quantity;\n }, 0);\n\n // NOTE (Jasmine, 2026-07-22): Trust the provider's authoritative cost when\n // present. For Shopify this is the server-computed cart cost (including a\n // legitimate $0 when items aren't purchasable), which we must not\n // second-guess; cookie carts keep their cost truthful via\n // cookie-cart-persistence.ts.\n const total = cart?.cost.totalAmount ?? lineItemSubtotal;\n\n // If we have provider cost data, use subtotalAmount which doesn't include discounts\n const actualSubtotal = cart?.cost.subtotalAmount ?? lineItemSubtotal;\n const discountAmount = actualSubtotal - total;\n\n const totalSavings = compareAtSubtotal - total;\n\n return {\n subtotal: lineItemSubtotal,\n discountAmount,\n totalSavings,\n total,\n };\n}\n\n/**\n *
|
|
5
|
-
"mappings": "AAEA,SAAS,0BAA0B;AAc5B,SAAS,2BAA2B,WAA+B;AACxE,SAAO,UAAU;AAAA,IACf,CAAC,KAAK,SAAS,MAAM,mBAAmB,IAAI,EAAE,aAAa,KAAK;AAAA,IAChE;AAAA,EACF;AACF;AAWO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAGe;AACb,QAAM,mBAAmB,2BAA2B,SAAS;AAC7D,QAAM,oBAAoB,UAAU,OAAO,CAAC,KAAK,SAAS;AACxD,WAAO,MAAM,mBAAmB,IAAI,EAAE,iBAAiB,KAAK;AAAA,EAC9D,GAAG,CAAC;AAOJ,QAAM,QAAQ,MAAM,KAAK,eAAe;AAGxC,QAAM,iBAAiB,MAAM,KAAK,kBAAkB;AACpD,QAAM,iBAAiB,iBAAiB;AAExC,QAAM,eAAe,oBAAoB;AAEzC,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;
|
|
4
|
+
"sourcesContent": ["import type { Cart, CartLine } from \"../cart-types\";\n\nimport { getCartLinePricing } from \"./variant-to-cart-line\";\n\nexport interface CartTotals {\n subtotal: number;\n discountAmount: number;\n totalSavings: number;\n total: number;\n}\n\n/**\n * Sum the final (post selling-plan) price of every line item in the cart.\n * This is the authoritative subtotal for cookie-based carts, which have no\n * server-computed cost to rely on.\n */\nexport function calculateLineItemsSubtotal(lineItems: CartLine[]): number {\n return lineItems.reduce(\n (sum, item) => sum + getCartLinePricing(item).finalPrice * item.quantity,\n 0,\n );\n}\n\n/**\n * Calculate cart totals including subtotal, discounts, and final total.\n * When cart cost data is provided (from Shopify), uses the actual totalAmount\n * which includes cart-level discounts from discount codes.\n *\n * @param options - Object containing lineItems and cart\n * @param options.lineItems - Array of cart line items\n * @param options.cart - Optional cart data from Shopify (includes discount codes)\n */\nexport function calculateCartTotals({\n lineItems,\n cart,\n}: {\n lineItems: CartLine[];\n cart: Cart | null;\n}): CartTotals {\n const lineItemSubtotal = calculateLineItemsSubtotal(lineItems);\n const compareAtSubtotal = lineItems.reduce((sum, item) => {\n return sum + getCartLinePricing(item).compareAtPrice * item.quantity;\n }, 0);\n\n // NOTE (Jasmine, 2026-07-22): Trust the provider's authoritative cost when\n // present. For Shopify this is the server-computed cart cost (including a\n // legitimate $0 when items aren't purchasable), which we must not\n // second-guess; cookie carts keep their cost truthful via\n // cookie-cart-persistence.ts.\n const total = cart?.cost.totalAmount ?? lineItemSubtotal;\n\n // If we have provider cost data, use subtotalAmount which doesn't include discounts\n const actualSubtotal = cart?.cost.subtotalAmount ?? lineItemSubtotal;\n const discountAmount = actualSubtotal - total;\n\n const totalSavings = compareAtSubtotal - total;\n\n return {\n subtotal: lineItemSubtotal,\n discountAmount,\n totalSavings,\n total,\n };\n}\n\n/**\n * Validates and formats a Shopify selling plan ID to ensure it has the correct GID format.\n *\n * @param sellingPlanId - The selling plan ID to validate and format\n * @returns The formatted selling plan ID with GID prefix, or null if no ID provided\n */\nexport function formatSellingPlanId(\n sellingPlanId: string | null | undefined,\n): string | null {\n if (!sellingPlanId) {\n return null;\n }\n\n // Check if it already has the gid format\n if (sellingPlanId.startsWith(\"gid://shopify/SellingPlan/\")) {\n return sellingPlanId;\n }\n\n // If it doesn't have the gid format, prepend it\n return `gid://shopify/SellingPlan/${sellingPlanId}`;\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,0BAA0B;AAc5B,SAAS,2BAA2B,WAA+B;AACxE,SAAO,UAAU;AAAA,IACf,CAAC,KAAK,SAAS,MAAM,mBAAmB,IAAI,EAAE,aAAa,KAAK;AAAA,IAChE;AAAA,EACF;AACF;AAWO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAGe;AACb,QAAM,mBAAmB,2BAA2B,SAAS;AAC7D,QAAM,oBAAoB,UAAU,OAAO,CAAC,KAAK,SAAS;AACxD,WAAO,MAAM,mBAAmB,IAAI,EAAE,iBAAiB,KAAK;AAAA,EAC9D,GAAG,CAAC;AAOJ,QAAM,QAAQ,MAAM,KAAK,eAAe;AAGxC,QAAM,iBAAiB,MAAM,KAAK,kBAAkB;AACpD,QAAM,iBAAiB,iBAAiB;AAExC,QAAM,eAAe,oBAAoB;AAEzC,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAQO,SAAS,oBACd,eACe;AACf,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AAGA,MAAI,cAAc,WAAW,4BAA4B,GAAG;AAC1D,WAAO;AAAA,EACT;AAGA,SAAO,6BAA6B,aAAa;AACnD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
import { fromMajorUnitsToMinorUnits } from "../../_vendor/schemas/money.mjs";
|
|
1
2
|
import { convertLegacyResourceIdToGraphQLId } from "../../lib/shopify-utils";
|
|
2
3
|
import { formatSellingPlanId } from "./cart-utils";
|
|
3
|
-
function applyPriceAdjustment(variantPrice, adjustment) {
|
|
4
|
+
function applyPriceAdjustment(variantPrice, adjustment, currencyCode) {
|
|
4
5
|
switch (adjustment.valueType) {
|
|
6
|
+
// NOTE (Max, 2026-08-03): variantPrice is integer minor units, but the
|
|
7
|
+
// loader emits money-typed adjustments as decimal major units (its
|
|
8
|
+
// storefront contract), so the price/fixedAmount arms convert here at the
|
|
9
|
+
// cart boundary. Percentage is unitless and needs no conversion.
|
|
5
10
|
case "price":
|
|
6
|
-
return
|
|
11
|
+
return fromMajorUnitsToMinorUnits({
|
|
12
|
+
amount: adjustment.value,
|
|
13
|
+
currencyCode
|
|
14
|
+
});
|
|
7
15
|
case "percentage":
|
|
8
|
-
return Math.max(
|
|
16
|
+
return Math.max(
|
|
17
|
+
0,
|
|
18
|
+
Math.round(variantPrice * (1 - adjustment.value / 100))
|
|
19
|
+
);
|
|
9
20
|
case "fixedAmount":
|
|
10
|
-
return Math.max(
|
|
21
|
+
return Math.max(
|
|
22
|
+
0,
|
|
23
|
+
variantPrice - fromMajorUnitsToMinorUnits({
|
|
24
|
+
amount: adjustment.value,
|
|
25
|
+
currencyCode
|
|
26
|
+
})
|
|
27
|
+
);
|
|
11
28
|
}
|
|
12
29
|
}
|
|
13
30
|
function variantToCartLine(variant, options) {
|
|
@@ -160,7 +177,7 @@ function createOptimisticSellingPlanAllocation({
|
|
|
160
177
|
description: sellingPlan.description
|
|
161
178
|
},
|
|
162
179
|
priceAdjustments: sellingPlan.priceAdjustments.map((adj) => {
|
|
163
|
-
const adjustedPrice = variantPrice !== void 0 ? applyPriceAdjustment(variantPrice, adj) : 0;
|
|
180
|
+
const adjustedPrice = variantPrice !== void 0 ? applyPriceAdjustment(variantPrice, adj, currencyCode) : 0;
|
|
164
181
|
return {
|
|
165
182
|
compareAtPrice: {
|
|
166
183
|
amount: variantPrice ?? 0,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../cart/utils/variant-to-cart-line.ts"],
|
|
4
|
-
"sourcesContent": ["import type { SellingPlanGroup } from \"../../loaders/loader-schemas\";\nimport type {\n CartLine,\n CartLineAttribute,\n CartLineMerchandise,\n CartLinePayload,\n SellingPlanAllocation,\n} from \"../cart-types\";\n\nimport { convertLegacyResourceIdToGraphQLId } from \"../../lib/shopify-utils\";\nimport { formatSellingPlanId } from \"./cart-utils\";\n\n// TODO: Temporary \u2014 minimal local type after removing features/product. Replace with loader/canonical variant type when data loaders are in place.\ninterface ProductVariant {\n id: string;\n externalId?: string;\n title: string;\n price: number;\n originalPrice: number | null;\n optionValues?: {\n id: string;\n value: string;\n color: string | null;\n image: string | null;\n imageUrls: string[];\n referenceType: \"SHOPIFY\" | \"REPLO\";\n }[];\n}\n\n// TODO: Temporary \u2014 inlined from removed features/product/utils/pricing-utils. Keep until cart uses canonical product/loader types.\nfunction applyPriceAdjustment(\n variantPrice: number,\n adjustment: {\n value: number;\n valueType: \"percentage\" | \"fixedAmount\" | \"price\";\n },\n): number {\n switch (adjustment.valueType) {\n case \"price\":\n return adjustment.value;\n case \"percentage\":\n return Math.max(0, variantPrice * (1 - adjustment.value / 100));\n case \"fixedAmount\":\n return Math.max(0, variantPrice - adjustment.value);\n }\n}\n\n// === Variant to Cart Line Conversion ===\n\nexport interface VariantToCartLineProduct {\n id: string;\n title: string;\n featuredMedia?: {\n type: string;\n url: string;\n alt?: string;\n } | null;\n sellingPlanGroups?: SellingPlanGroup[];\n}\n\ninterface VariantToCartLineOptions {\n quantity?: number;\n properties?: CartLineAttribute[];\n sellingPlanId?: string | null;\n pricing?: {\n compareAtPrice: number;\n discountPercentage: number;\n };\n bundle?: {\n bundleId: string;\n bundleDiscount: number;\n };\n includeMerchandise?: boolean;\n product?: VariantToCartLineProduct;\n}\n\n/**\n * Converts a product variant to a cart line payload.\n * This is the primary function for creating cart lines from variants.\n *\n * When a ProductVariant has both `price` and `originalPrice`, the function will\n * automatically calculate and include pricing attributes (compareAtPrice and discountPercentage)\n * unless explicitly overridden in the options.\n */\nexport function variantToCartLine(\n variant: ProductVariant,\n options?: VariantToCartLineOptions,\n): CartLinePayload {\n const quantity = options?.quantity ?? 1;\n const baseProperties = options?.properties ?? [];\n const sellingPlanId = formatSellingPlanId(options?.sellingPlanId ?? null);\n\n // Create additional properties based on options\n const additionalProperties: CartLineAttribute[] = [];\n\n if (options?.bundle) {\n additionalProperties.push(\n ...createBundleAttributes(\n options.bundle.bundleId,\n options.bundle.bundleDiscount,\n ),\n );\n }\n\n const allProperties = [...baseProperties, ...additionalProperties];\n\n const cartLine: CartLinePayload = {\n id: variant.externalId\n ? convertLegacyResourceIdToGraphQLId(variant.externalId, \"ProductVariant\")\n : variant.id,\n quantity,\n properties: allProperties,\n sellingPlanId,\n };\n\n // Add merchandise if requested and we have product data\n if (options?.includeMerchandise && options.product) {\n const { product } = options;\n\n cartLine.merchandise = {\n id: variant.externalId\n ? convertLegacyResourceIdToGraphQLId(\n variant.externalId,\n \"ProductVariant\",\n )\n : variant.id,\n product: {\n id: product.id,\n title: product.title,\n sellingPlanGroups: product.sellingPlanGroups,\n },\n title: variant.title ?? `${product.title} - ${variant.id}`,\n price: variant.price ?? 0,\n compareAtPrice: variant.originalPrice,\n image:\n product.featuredMedia?.type === \"image\"\n ? {\n url: product.featuredMedia.url,\n altText: product.featuredMedia.alt ?? product.title,\n }\n : null,\n selectedOptions:\n variant.optionValues?.map((opt) => ({\n name: opt.value,\n value: opt.value,\n })) ?? [],\n };\n }\n\n return cartLine;\n}\n\n// === Cart Attributes Functions ===\n\n/**\n * Creates cart line attributes for bundle items.\n *\n * @param bundleId - The ID of the bundle\n * @param bundleDiscount - The discount amount for the bundle\n * @returns Array of cart line attributes for bundle metadata\n */\nfunction createBundleAttributes(\n bundleId: string,\n bundleDiscount: number,\n): CartLineAttribute[] {\n return [\n { key: \"bundleId\", value: bundleId },\n { key: \"bundleDiscount\", value: bundleDiscount },\n { key: \"isBundleItem\", value: true },\n ];\n}\n\n// === Cart Line Utilities ===\n\n/**\n * Gets a specific attribute value from a cart line.\n *\n * @param cartLine - The cart line to get the attribute from\n * @param key - The attribute key to retrieve\n * @returns The attribute value, or undefined if not found\n */\nexport function getCartLineAttribute(\n cartLine: CartLine,\n key: string,\n): string | number | boolean | undefined {\n return cartLine.attributes.find((attr: CartLineAttribute) => attr.key === key)\n ?.value;\n}\n\n/**\n * Calculates pricing information for a cart line, including discounts and\n * selling plan adjustments.\n *\n * @param cartLine - The cart line to calculate pricing for\n * @returns Object containing compareAtPrice, discountPercentage, hasDiscount, sellingPlanAdjustedPrice, and finalPrice\n */\nexport function getCartLinePricing(cartLine: CartLine) {\n if (!cartLine.merchandise) {\n return {\n compareAtPrice: 0,\n discountPercentage: 0,\n hasDiscount: false,\n sellingPlanAdjustedPrice: 0,\n finalPrice: 0,\n };\n }\n\n const compareAtPrice = cartLine.merchandise.compareAtPrice ?? 0;\n const currentPrice = cartLine.merchandise.price;\n const discountPercentage =\n compareAtPrice > currentPrice\n ? ((compareAtPrice - currentPrice) / compareAtPrice) * 100\n : 0;\n const hasDiscount = compareAtPrice > currentPrice;\n\n let sellingPlanAdjustedPrice = cartLine.merchandise.price;\n if (\n cartLine.sellingPlanAllocation &&\n cartLine.sellingPlanAllocation.priceAdjustments.length > 0 &&\n cartLine.sellingPlanAllocation.priceAdjustments[0]?.price\n ) {\n // Use the price from the first price adjustment, which represents the selling plan price\n sellingPlanAdjustedPrice =\n cartLine.sellingPlanAllocation.priceAdjustments[0]!.price.amount;\n }\n\n return {\n compareAtPrice,\n discountPercentage,\n hasDiscount: hasDiscount,\n sellingPlanAdjustedPrice,\n finalPrice: sellingPlanAdjustedPrice,\n };\n}\n\n/**\n * Extracts bundle information from cart line attributes.\n *\n * @param cartLine - The cart line to get bundle info from\n * @returns Object containing bundle ID, discount, and whether it's a bundle item\n */\nexport function getCartLineBundleInfo(cartLine: CartLine) {\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const bundleId = getCartLineAttribute(cartLine, \"bundleId\") as string;\n const bundleDiscount = Number(\n getCartLineAttribute(cartLine, \"bundleDiscount\") ?? 0,\n );\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const isBundleItem = getCartLineAttribute(\n cartLine,\n \"isBundleItem\",\n ) as boolean;\n\n return {\n bundleId: bundleId ?? null,\n bundleDiscount,\n isBundleItem: isBundleItem ?? false,\n };\n}\n\n/**\n * Extracts special item information from cart line attributes.\n *\n * @param cartLine - The cart line to get special info from\n * @returns Object containing whether it's a special item and any special instructions\n */\nexport function getCartLineSpecialInfo(cartLine: CartLine) {\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const isSpecialItem = getCartLineAttribute(\n cartLine,\n \"isSpecialItem\",\n ) as boolean;\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const specialInstructions = getCartLineAttribute(\n cartLine,\n \"specialInstructions\",\n ) as string;\n\n return {\n isSpecialItem: isSpecialItem ?? false,\n specialInstructions: specialInstructions\n ? specialInstructions.split(\"|\")\n : [],\n };\n}\n\n/**\n * Extracts subscription (selling plan) information from a cart line.\n *\n * @param cartLine - The cart line to get subscription info from\n * @returns Object containing isSubscription, frequency, discount, and sellingPlan\n */\nexport function getCartLineSubscriptionInfo(cartLine: CartLine) {\n if (cartLine.sellingPlanAllocation) {\n return {\n isSubscription: true,\n frequency: cartLine.sellingPlanAllocation.sellingPlan.name,\n discount: 0, // Shopify calculates this from price adjustments when available\n sellingPlan: cartLine.sellingPlanAllocation.sellingPlan,\n };\n }\n\n // No subscription if no sellingPlanAllocation\n return {\n isSubscription: false,\n frequency: null,\n discount: 0,\n sellingPlan: null,\n };\n}\n\n/**\n * Creates an optimistic selling plan allocation using product data.\n * This matches the exact structure that Shopify returns so the UI doesn't need conditional logic.\n */\nexport function createOptimisticSellingPlanAllocation({\n merchandise,\n sellingPlanId,\n currencyCode = \"USD\",\n}: {\n merchandise: CartLineMerchandise;\n sellingPlanId: string | null;\n currencyCode?: string;\n}): SellingPlanAllocation | null {\n const { product, price: variantPrice } = merchandise;\n\n if (!sellingPlanId || !product.sellingPlanGroups) {\n return null;\n }\n\n // Find the selling plan in the product's selling plan groups\n for (const group of product.sellingPlanGroups) {\n const sellingPlan = group.sellingPlans.find(\n (sp) => sp.id === sellingPlanId,\n );\n if (sellingPlan) {\n return {\n sellingPlan: {\n id: sellingPlan.id,\n name: sellingPlan.name,\n description: sellingPlan.description,\n },\n priceAdjustments: sellingPlan.priceAdjustments.map((adj) => {\n const adjustedPrice =\n variantPrice !== undefined\n ? applyPriceAdjustment(variantPrice, adj)\n : 0;\n\n return {\n compareAtPrice: {\n amount: variantPrice ?? 0,\n currencyCode,\n },\n perDeliveryPrice: {\n amount: adjustedPrice,\n currencyCode,\n },\n price: {\n amount: adjustedPrice,\n currencyCode,\n },\n unitPrice: null,\n };\n }),\n checkoutChargeAmount: {\n amount: 0,\n currencyCode,\n },\n remainingBalanceChargeAmount: {\n amount: 0,\n currencyCode,\n },\n };\n }\n }\n\n return null;\n}\n"],
|
|
5
|
-
"mappings": "AASA,SAAS,0CAA0C;AACnD,SAAS,2BAA2B;AAoBpC,SAAS,qBACP,cACA,
|
|
4
|
+
"sourcesContent": ["import type { SellingPlanGroup } from \"../../loaders/loader-schemas\";\nimport type {\n CartLine,\n CartLineAttribute,\n CartLineMerchandise,\n CartLinePayload,\n SellingPlanAllocation,\n} from \"../cart-types\";\n\nimport { fromMajorUnitsToMinorUnits } from \"schemas/money\";\n\nimport { convertLegacyResourceIdToGraphQLId } from \"../../lib/shopify-utils\";\nimport { formatSellingPlanId } from \"./cart-utils\";\n\n// TODO: Temporary \u2014 minimal local type after removing features/product. Replace with loader/canonical variant type when data loaders are in place.\ninterface ProductVariant {\n id: string;\n externalId?: string;\n title: string;\n price: number;\n originalPrice: number | null;\n optionValues?: {\n id: string;\n value: string;\n color: string | null;\n image: string | null;\n imageUrls: string[];\n referenceType: \"SHOPIFY\" | \"REPLO\";\n }[];\n}\n\n// TODO: Temporary \u2014 inlined from removed features/product/utils/pricing-utils. Keep until cart uses canonical product/loader types.\nfunction applyPriceAdjustment(\n variantPrice: number,\n adjustment: {\n value: number;\n valueType: \"percentage\" | \"fixedAmount\" | \"price\";\n },\n currencyCode: string,\n): number {\n switch (adjustment.valueType) {\n // NOTE (Max, 2026-08-03): variantPrice is integer minor units, but the\n // loader emits money-typed adjustments as decimal major units (its\n // storefront contract), so the price/fixedAmount arms convert here at the\n // cart boundary. Percentage is unitless and needs no conversion.\n case \"price\":\n return fromMajorUnitsToMinorUnits({\n amount: adjustment.value,\n currencyCode,\n });\n case \"percentage\":\n return Math.max(\n 0,\n Math.round(variantPrice * (1 - adjustment.value / 100)),\n );\n case \"fixedAmount\":\n return Math.max(\n 0,\n variantPrice -\n fromMajorUnitsToMinorUnits({\n amount: adjustment.value,\n currencyCode,\n }),\n );\n }\n}\n\n// === Variant to Cart Line Conversion ===\n\nexport interface VariantToCartLineProduct {\n id: string;\n title: string;\n featuredMedia?: {\n type: string;\n url: string;\n alt?: string;\n } | null;\n sellingPlanGroups?: SellingPlanGroup[];\n}\n\ninterface VariantToCartLineOptions {\n quantity?: number;\n properties?: CartLineAttribute[];\n sellingPlanId?: string | null;\n pricing?: {\n compareAtPrice: number;\n discountPercentage: number;\n };\n bundle?: {\n bundleId: string;\n bundleDiscount: number;\n };\n includeMerchandise?: boolean;\n product?: VariantToCartLineProduct;\n}\n\n/**\n * Converts a product variant to a cart line payload.\n * This is the primary function for creating cart lines from variants.\n *\n * When a ProductVariant has both `price` and `originalPrice`, the function will\n * automatically calculate and include pricing attributes (compareAtPrice and discountPercentage)\n * unless explicitly overridden in the options.\n */\nexport function variantToCartLine(\n variant: ProductVariant,\n options?: VariantToCartLineOptions,\n): CartLinePayload {\n const quantity = options?.quantity ?? 1;\n const baseProperties = options?.properties ?? [];\n const sellingPlanId = formatSellingPlanId(options?.sellingPlanId ?? null);\n\n // Create additional properties based on options\n const additionalProperties: CartLineAttribute[] = [];\n\n if (options?.bundle) {\n additionalProperties.push(\n ...createBundleAttributes(\n options.bundle.bundleId,\n options.bundle.bundleDiscount,\n ),\n );\n }\n\n const allProperties = [...baseProperties, ...additionalProperties];\n\n const cartLine: CartLinePayload = {\n id: variant.externalId\n ? convertLegacyResourceIdToGraphQLId(variant.externalId, \"ProductVariant\")\n : variant.id,\n quantity,\n properties: allProperties,\n sellingPlanId,\n };\n\n // Add merchandise if requested and we have product data\n if (options?.includeMerchandise && options.product) {\n const { product } = options;\n\n cartLine.merchandise = {\n id: variant.externalId\n ? convertLegacyResourceIdToGraphQLId(\n variant.externalId,\n \"ProductVariant\",\n )\n : variant.id,\n product: {\n id: product.id,\n title: product.title,\n sellingPlanGroups: product.sellingPlanGroups,\n },\n title: variant.title ?? `${product.title} - ${variant.id}`,\n price: variant.price ?? 0,\n compareAtPrice: variant.originalPrice,\n image:\n product.featuredMedia?.type === \"image\"\n ? {\n url: product.featuredMedia.url,\n altText: product.featuredMedia.alt ?? product.title,\n }\n : null,\n selectedOptions:\n variant.optionValues?.map((opt) => ({\n name: opt.value,\n value: opt.value,\n })) ?? [],\n };\n }\n\n return cartLine;\n}\n\n// === Cart Attributes Functions ===\n\n/**\n * Creates cart line attributes for bundle items.\n *\n * @param bundleId - The ID of the bundle\n * @param bundleDiscount - The discount amount for the bundle\n * @returns Array of cart line attributes for bundle metadata\n */\nfunction createBundleAttributes(\n bundleId: string,\n bundleDiscount: number,\n): CartLineAttribute[] {\n return [\n { key: \"bundleId\", value: bundleId },\n { key: \"bundleDiscount\", value: bundleDiscount },\n { key: \"isBundleItem\", value: true },\n ];\n}\n\n// === Cart Line Utilities ===\n\n/**\n * Gets a specific attribute value from a cart line.\n *\n * @param cartLine - The cart line to get the attribute from\n * @param key - The attribute key to retrieve\n * @returns The attribute value, or undefined if not found\n */\nexport function getCartLineAttribute(\n cartLine: CartLine,\n key: string,\n): string | number | boolean | undefined {\n return cartLine.attributes.find((attr: CartLineAttribute) => attr.key === key)\n ?.value;\n}\n\n/**\n * Calculates pricing information for a cart line, including discounts and\n * selling plan adjustments.\n *\n * @param cartLine - The cart line to calculate pricing for\n * @returns Object containing compareAtPrice, discountPercentage, hasDiscount, sellingPlanAdjustedPrice, and finalPrice\n */\nexport function getCartLinePricing(cartLine: CartLine) {\n if (!cartLine.merchandise) {\n return {\n compareAtPrice: 0,\n discountPercentage: 0,\n hasDiscount: false,\n sellingPlanAdjustedPrice: 0,\n finalPrice: 0,\n };\n }\n\n const compareAtPrice = cartLine.merchandise.compareAtPrice ?? 0;\n const currentPrice = cartLine.merchandise.price;\n const discountPercentage =\n compareAtPrice > currentPrice\n ? ((compareAtPrice - currentPrice) / compareAtPrice) * 100\n : 0;\n const hasDiscount = compareAtPrice > currentPrice;\n\n let sellingPlanAdjustedPrice = cartLine.merchandise.price;\n if (\n cartLine.sellingPlanAllocation &&\n cartLine.sellingPlanAllocation.priceAdjustments.length > 0 &&\n cartLine.sellingPlanAllocation.priceAdjustments[0]?.price\n ) {\n // Use the price from the first price adjustment, which represents the selling plan price\n sellingPlanAdjustedPrice =\n cartLine.sellingPlanAllocation.priceAdjustments[0]!.price.amount;\n }\n\n return {\n compareAtPrice,\n discountPercentage,\n hasDiscount: hasDiscount,\n sellingPlanAdjustedPrice,\n finalPrice: sellingPlanAdjustedPrice,\n };\n}\n\n/**\n * Extracts bundle information from cart line attributes.\n *\n * @param cartLine - The cart line to get bundle info from\n * @returns Object containing bundle ID, discount, and whether it's a bundle item\n */\nexport function getCartLineBundleInfo(cartLine: CartLine) {\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const bundleId = getCartLineAttribute(cartLine, \"bundleId\") as string;\n const bundleDiscount = Number(\n getCartLineAttribute(cartLine, \"bundleDiscount\") ?? 0,\n );\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const isBundleItem = getCartLineAttribute(\n cartLine,\n \"isBundleItem\",\n ) as boolean;\n\n return {\n bundleId: bundleId ?? null,\n bundleDiscount,\n isBundleItem: isBundleItem ?? false,\n };\n}\n\n/**\n * Extracts special item information from cart line attributes.\n *\n * @param cartLine - The cart line to get special info from\n * @returns Object containing whether it's a special item and any special instructions\n */\nexport function getCartLineSpecialInfo(cartLine: CartLine) {\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const isSpecialItem = getCartLineAttribute(\n cartLine,\n \"isSpecialItem\",\n ) as boolean;\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const specialInstructions = getCartLineAttribute(\n cartLine,\n \"specialInstructions\",\n ) as string;\n\n return {\n isSpecialItem: isSpecialItem ?? false,\n specialInstructions: specialInstructions\n ? specialInstructions.split(\"|\")\n : [],\n };\n}\n\n/**\n * Extracts subscription (selling plan) information from a cart line.\n *\n * @param cartLine - The cart line to get subscription info from\n * @returns Object containing isSubscription, frequency, discount, and sellingPlan\n */\nexport function getCartLineSubscriptionInfo(cartLine: CartLine) {\n if (cartLine.sellingPlanAllocation) {\n return {\n isSubscription: true,\n frequency: cartLine.sellingPlanAllocation.sellingPlan.name,\n discount: 0, // Shopify calculates this from price adjustments when available\n sellingPlan: cartLine.sellingPlanAllocation.sellingPlan,\n };\n }\n\n // No subscription if no sellingPlanAllocation\n return {\n isSubscription: false,\n frequency: null,\n discount: 0,\n sellingPlan: null,\n };\n}\n\n/**\n * Creates an optimistic selling plan allocation using product data.\n * This matches the exact structure that Shopify returns so the UI doesn't need conditional logic.\n */\nexport function createOptimisticSellingPlanAllocation({\n merchandise,\n sellingPlanId,\n currencyCode = \"USD\",\n}: {\n merchandise: CartLineMerchandise;\n sellingPlanId: string | null;\n currencyCode?: string;\n}): SellingPlanAllocation | null {\n const { product, price: variantPrice } = merchandise;\n\n if (!sellingPlanId || !product.sellingPlanGroups) {\n return null;\n }\n\n // Find the selling plan in the product's selling plan groups\n for (const group of product.sellingPlanGroups) {\n const sellingPlan = group.sellingPlans.find(\n (sp) => sp.id === sellingPlanId,\n );\n if (sellingPlan) {\n return {\n sellingPlan: {\n id: sellingPlan.id,\n name: sellingPlan.name,\n description: sellingPlan.description,\n },\n priceAdjustments: sellingPlan.priceAdjustments.map((adj) => {\n const adjustedPrice =\n variantPrice !== undefined\n ? applyPriceAdjustment(variantPrice, adj, currencyCode)\n : 0;\n\n return {\n compareAtPrice: {\n amount: variantPrice ?? 0,\n currencyCode,\n },\n perDeliveryPrice: {\n amount: adjustedPrice,\n currencyCode,\n },\n price: {\n amount: adjustedPrice,\n currencyCode,\n },\n unitPrice: null,\n };\n }),\n checkoutChargeAmount: {\n amount: 0,\n currencyCode,\n },\n remainingBalanceChargeAmount: {\n amount: 0,\n currencyCode,\n },\n };\n }\n }\n\n return null;\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isObject_default } from './chunk-
|
|
1
|
+
import { isObject_default } from './chunk-ILGEM42C.mjs';
|
|
2
2
|
import { root_default, isObjectLike_default, freeGlobal_default, baseGetTag_default, Symbol_default, isArray_default } from './chunk-FNTGY7I5.mjs';
|
|
3
3
|
|
|
4
4
|
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheClear.js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function DocumentReadyBeacon(): import("react/jsx-runtime").JSX.Element
|
|
1
|
+
export declare function DocumentReadyBeacon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
const BEACON_SCRIPT = `if (window.parent !== window) { window.parent.postMessage({ type: "replo:preview:status", status: "ok", phase: "document", route: window.location.pathname }, "*"); }`;
|
|
3
3
|
function DocumentReadyBeacon() {
|
|
4
|
-
if (process.env.NODE_ENV !== "development") {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
4
|
return /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: BEACON_SCRIPT } });
|
|
8
5
|
}
|
|
9
6
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../editor/DocumentReadyBeacon.tsx"],
|
|
4
|
-
"sourcesContent": ["// Posts at HTML parse time, pre-hydration; error shells and retry pages are different documents without this script, so receiving it proves the real site's document arrived.\n// phase: \"document\" lets the editor distinguish this from the hydration-time reporter \u2014 document arrival must not disarm its JS-boot watchdog.\nconst BEACON_SCRIPT = `if (window.parent !== window) { window.parent.postMessage({ type: \"replo:preview:status\", status: \"ok\", phase: \"document\", route: window.location.pathname }, \"*\"); }`;\n\nexport function DocumentReadyBeacon() {\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["// Posts at HTML parse time, pre-hydration; error shells and retry pages are different documents without this script, so receiving it proves the real site's document arrived.\n// phase: \"document\" lets the editor distinguish this from the hydration-time reporter \u2014 document arrival must not disarm its JS-boot watchdog.\nconst BEACON_SCRIPT = `if (window.parent !== window) { window.parent.postMessage({ type: \"replo:preview:status\", status: \"ok\", phase: \"document\", route: window.location.pathname }, \"*\"); }`;\n\nexport function DocumentReadyBeacon() {\n return <script dangerouslySetInnerHTML={{ __html: BEACON_SCRIPT }} />;\n}\n"],
|
|
5
|
+
"mappings": "AAKS;AAHT,MAAM,gBAAgB;AAEf,SAAS,sBAAsB;AACpC,SAAO,oBAAC,YAAO,yBAAyB,EAAE,QAAQ,cAAc,GAAG;AACrE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
const
|
|
3
|
+
const RED_CHROME_SELECTOR = '[data-next-badge][data-error="true"], [data-nextjs-dialog]';
|
|
4
|
+
const BLOCKING_ERROR_SELECTOR = "[data-nextjs-dialog]";
|
|
4
5
|
const STATUS_LATCH_MS = 500;
|
|
5
6
|
function NextErrorReporter() {
|
|
6
7
|
React.useEffect(() => {
|
|
@@ -61,11 +62,13 @@ function NextErrorReporter() {
|
|
|
61
62
|
});
|
|
62
63
|
observedRoot = root;
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
portal.style.display = portal.shadowRoot?.querySelector(
|
|
66
|
+
RED_CHROME_SELECTOR
|
|
67
|
+
) ? "none" : "";
|
|
68
|
+
const hasBlockingError = Boolean(
|
|
69
|
+
portal.shadowRoot?.querySelector(BLOCKING_ERROR_SELECTOR)
|
|
66
70
|
);
|
|
67
|
-
|
|
68
|
-
post(showingError ? "error" : "ok");
|
|
71
|
+
post(hasBlockingError ? "error" : "ok");
|
|
69
72
|
};
|
|
70
73
|
const lightObserver = new MutationObserver(syncOverlayState);
|
|
71
74
|
lightObserver.observe(document.documentElement, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../editor/NextErrorReporter.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * NOTE (Max, 2026-06-10): This component sends post messages to its embedder (website-builder miniapp)\n * so that it can render a loading / error UI if there's an error on this page.\n *\n * Ideally, we wouldn't need any update to canopy-sdk to achieve this: the miniapp would just read the\n * iframe's content and detect whenever there's a nextjs error overlay.\n * But the preview runs cross-origin from the editor, so the editor can't read the iframe's\n * DOM (browser security).\n *\n * This component has observers that detect when the nextjs error overlay appears or\n * disappears, and sends a post message with a status:\n * - `status`: \"error\" while Next's dev overlay
|
|
5
|
-
"mappings": ";AAEA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * NOTE (Max, 2026-06-10): This component sends post messages to its embedder (website-builder miniapp)\n * so that it can render a loading / error UI if there's an error on this page.\n *\n * Ideally, we wouldn't need any update to canopy-sdk to achieve this: the miniapp would just read the\n * iframe's content and detect whenever there's a nextjs error overlay.\n * But the preview runs cross-origin from the editor, so the editor can't read the iframe's\n * DOM (browser security).\n *\n * This component has observers that detect when the nextjs error overlay appears or\n * disappears, and sends a post message with a status:\n * - `status`: \"error\" while Next's dev overlay opens its blocking error dialog\n * (a real page break \u2014 see the selectors below for why the badge's issue\n * count is deliberately NOT used: it also counts recovered loader misses)\n * - `status`: \"ok\" otherwise. Cleared by Fast Refresh on a fix, so it's also the\n * recovery signal (agent fixed the error, so it's the error -> ok transition)\n *\n * It also hides Next's dev error overlay (`<nextjs-portal>`) at the source the\n * instant an error appears, so the red bubble never paints \u2014 the MutationObserver\n * callback runs as a microtask before paint. `data-error` stays queryable while\n * hidden, so detection is unaffected;\n *\n * The overlay lives in `<nextjs-portal>`'s shadow root, which Next can recreate,\n * so we re-attach the shadow observer whenever it hands us a new root. No polling.\n *\n * This must be mounted OUTSIDE the error boundary (see ReploProvider) so it keeps\n * reporting while the boundary is caught (and showing its neutral cover).\n *\n * I'm unsatisfied with this approach: observing for the nextjs-portal is brittle and ugly.\n * Ideally, the ClientErrorBoundary, which hooks into the render cycle, in componentDidCatch, would\n * just report a post message to the miniapp. I prototyped that, the error detection works\n * great (ok -> error transition).\n * But the error -> ok transition doesn't work for Server components (it only does for Client\n * components). Here's a slack thread with me <> Gabe on it:\n * https://replohq.slack.com/archives/C03AACVP08Y/p1781154057832689?thread_ts=1781029224.564489&cid=C03AACVP08Y.\n */\n// NOTE (Max, 2026-08-04): <nextjs-portal> surfaces two very different things,\n// and only one of them means the page is actually broken:\n// - the dev-tools badge (`[data-next-badge][data-error=\"true\"]`) lights for\n// EVERY collected issue, including a server-side loader error that React\n// already recovered from by streaming the LoaderErrorBoundary fallback. That\n// is a graceful, recoverable miss (product unpublished, deleted collection,\n// \u2026) \u2014 the page renders fine \u2014 and it must NOT be reported as a page error.\n// - the error overlay dialog (`[data-nextjs-dialog]`) only mounts when Next\n// auto-opens the overlay for a genuinely blocking error: the app shell's\n// error boundary catching an uncaught render crash, an unrecoverable SSR\n// error (missing root tags), or a build error. Next never auto-opens the\n// dialog for a recovered error. Verified against next@16.1.7 (the version\n// canopy-sdk and most templates pin) and next@15.3.8: the sole auto-open\n// is AppDevOverlayErrorBoundary's componentDidCatch -> openErrorOverlay,\n// i.e. the shell boundary, which a nested LoaderErrorBoundary never reaches\n// (a caught loader miss only increments the badge count). The badge count\n// opens the dialog only on an explicit user click.\n// So the open dialog \u2014 not the badge's issue count \u2014 is the fatal-vs-recoverable\n// discriminator. Keying off the badge reported recoverable loader misses as\n// full-page errors, blanking a preview that had actually rendered its fallback.\n//\n// We still *hide* the whole portal whenever Next paints red chrome (the errored\n// badge OR the dialog) so no dev overlay bleeds into the preview \u2014 a recovered\n// loader miss shouldn't flash a red dot either. Only the blocking dialog is\n// reported upward as a page error.\nconst RED_CHROME_SELECTOR =\n '[data-next-badge][data-error=\"true\"], [data-nextjs-dialog]';\nconst BLOCKING_ERROR_SELECTOR = \"[data-nextjs-dialog]\";\n\n// HMR portal churn flips the overlay for milliseconds in both directions; only a state that persists this long is real.\nconst STATUS_LATCH_MS = 500;\n\ntype PreviewStatus = \"ok\" | \"error\";\n\nexport function NextErrorReporter() {\n // eslint-disable-next-line replo/no-use-effect -- Observes Next's dev error overlay (a shadow-DOM node outside React's tree) and relays its state to the cross-origin embedder. No React alternative applies.\n React.useEffect(() => {\n let lastStatus: PreviewStatus | null = null;\n let shadowObserver: MutationObserver | null = null;\n let observedRoot: ShadowRoot | null = null;\n let pendingPost: { status: PreviewStatus; timeoutId: number } | null = null;\n\n const postNow = (status: PreviewStatus) => {\n if (status === lastStatus) {\n return;\n }\n lastStatus = status;\n window.parent.postMessage(\n {\n type: \"replo:preview:status\",\n status,\n route: window.location.pathname,\n },\n \"*\",\n );\n };\n\n // Latch every transition (the opposite observation cancels a pending one) \u2014 a false error <-> ok flip makes the editor reload the preview. Only the initial \"ok\" posts immediately, as the readiness signal.\n const post = (status: PreviewStatus) => {\n if (pendingPost) {\n if (pendingPost.status === status) {\n return;\n }\n window.clearTimeout(pendingPost.timeoutId);\n pendingPost = null;\n }\n if (status === lastStatus) {\n return;\n }\n if (lastStatus === null && status === \"ok\") {\n postNow(\"ok\");\n return;\n }\n const timeoutId = window.setTimeout(() => {\n pendingPost = null;\n postNow(status);\n }, STATUS_LATCH_MS);\n pendingPost = { status, timeoutId };\n };\n\n // NOTE (Max, 2026-06-10): Reads the dev overlay's current error state and\n // propagates it \u2014 re-attach the shadow observer to the live root, hide the\n // portal while erroring, and post ok/error up to the editor. Runs on init and\n // on every observed DOM mutation.\n const syncOverlayState = () => {\n const portal = document.getElementsByTagName(\"nextjs-portal\")[0];\n if (!(portal instanceof HTMLElement)) {\n post(\"ok\");\n return;\n }\n // NOTE (Max, 2026-06-10): Re-attach whenever Next hands us a fresh shadow\n // root, else we'd keep watching a detached one after the overlay is\n // recreated.\n const root = portal.shadowRoot;\n if (root && root !== observedRoot) {\n shadowObserver?.disconnect();\n shadowObserver = new MutationObserver(syncOverlayState);\n shadowObserver.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"data-error\"],\n });\n observedRoot = root;\n }\n // NOTE (Max, 2026-06-10): Hide the dev overlay at the source so the red\n // bubble never paints \u2014 for any red chrome, including a recovered miss's\n // errored badge.\n portal.style.display = portal.shadowRoot?.querySelector(\n RED_CHROME_SELECTOR,\n )\n ? \"none\"\n : \"\";\n // Only the blocking overlay dialog means the page actually broke; the\n // badge's issue count also covers recovered loader misses (see selectors).\n const hasBlockingError = Boolean(\n portal.shadowRoot?.querySelector(BLOCKING_ERROR_SELECTOR),\n );\n post(hasBlockingError ? \"error\" : \"ok\");\n };\n\n // NOTE (Max, 2026-06-10): Catches the portal being added/removed in the light\n // DOM; the re-attached shadow observer catches in-overlay changes.\n const lightObserver = new MutationObserver(syncOverlayState);\n lightObserver.observe(document.documentElement, {\n childList: true,\n subtree: true,\n });\n syncOverlayState();\n\n return () => {\n lightObserver.disconnect();\n shadowObserver?.disconnect();\n if (pendingPost) {\n window.clearTimeout(pendingPost.timeoutId);\n }\n };\n }, []);\n\n return null;\n}\n"],
|
|
5
|
+
"mappings": ";AAEA,YAAY,WAAW;AA+DvB,MAAM,sBACJ;AACF,MAAM,0BAA0B;AAGhC,MAAM,kBAAkB;AAIjB,SAAS,oBAAoB;AAElC,QAAM,UAAU,MAAM;AACpB,QAAI,aAAmC;AACvC,QAAI,iBAA0C;AAC9C,QAAI,eAAkC;AACtC,QAAI,cAAmE;AAEvE,UAAM,UAAU,CAAC,WAA0B;AACzC,UAAI,WAAW,YAAY;AACzB;AAAA,MACF;AACA,mBAAa;AACb,aAAO,OAAO;AAAA,QACZ;AAAA,UACE,MAAM;AAAA,UACN;AAAA,UACA,OAAO,OAAO,SAAS;AAAA,QACzB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAGA,UAAM,OAAO,CAAC,WAA0B;AACtC,UAAI,aAAa;AACf,YAAI,YAAY,WAAW,QAAQ;AACjC;AAAA,QACF;AACA,eAAO,aAAa,YAAY,SAAS;AACzC,sBAAc;AAAA,MAChB;AACA,UAAI,WAAW,YAAY;AACzB;AAAA,MACF;AACA,UAAI,eAAe,QAAQ,WAAW,MAAM;AAC1C,gBAAQ,IAAI;AACZ;AAAA,MACF;AACA,YAAM,YAAY,OAAO,WAAW,MAAM;AACxC,sBAAc;AACd,gBAAQ,MAAM;AAAA,MAChB,GAAG,eAAe;AAClB,oBAAc,EAAE,QAAQ,UAAU;AAAA,IACpC;AAMA,UAAM,mBAAmB,MAAM;AAC7B,YAAM,SAAS,SAAS,qBAAqB,eAAe,EAAE,CAAC;AAC/D,UAAI,EAAE,kBAAkB,cAAc;AACpC,aAAK,IAAI;AACT;AAAA,MACF;AAIA,YAAM,OAAO,OAAO;AACpB,UAAI,QAAQ,SAAS,cAAc;AACjC,wBAAgB,WAAW;AAC3B,yBAAiB,IAAI,iBAAiB,gBAAgB;AACtD,uBAAe,QAAQ,MAAM;AAAA,UAC3B,WAAW;AAAA,UACX,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,iBAAiB,CAAC,YAAY;AAAA,QAChC,CAAC;AACD,uBAAe;AAAA,MACjB;AAIA,aAAO,MAAM,UAAU,OAAO,YAAY;AAAA,QACxC;AAAA,MACF,IACI,SACA;AAGJ,YAAM,mBAAmB;AAAA,QACvB,OAAO,YAAY,cAAc,uBAAuB;AAAA,MAC1D;AACA,WAAK,mBAAmB,UAAU,IAAI;AAAA,IACxC;AAIA,UAAM,gBAAgB,IAAI,iBAAiB,gBAAgB;AAC3D,kBAAc,QAAQ,SAAS,iBAAiB;AAAA,MAC9C,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AACD,qBAAiB;AAEjB,WAAO,MAAM;AACX,oBAAc,WAAW;AACzB,sBAAgB,WAAW;AAC3B,UAAI,aAAa;AACf,eAAO,aAAa,YAAY,SAAS;AAAA,MAC3C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* ```tsx
|
|
7
7
|
* import { useFormattedPrice } from "canopy-sdk/hooks/use-formatted-price";
|
|
8
8
|
*
|
|
9
|
-
* const originalPrice =
|
|
9
|
+
* const originalPrice = 1999; // integer minor units
|
|
10
10
|
* const originalPriceFormatted = useFormattedPrice(originalPrice, "USD");
|
|
11
11
|
* // Display the formatted price
|
|
12
12
|
* <p>{originalPriceFormatted}</p>;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { formatAmount } from "../_vendor/schemas/money.mjs";
|
|
1
2
|
import { useClientValue } from "./use-client-value";
|
|
2
3
|
const useFormattedPrice = (price, currency) => {
|
|
3
4
|
const navigatorLanguage = useClientValue(
|
|
4
5
|
() => window.navigator.language,
|
|
5
6
|
"en-US"
|
|
6
7
|
);
|
|
7
|
-
if (
|
|
8
|
+
if (price === null) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
return formatAmount({
|
|
12
|
+
amount: price,
|
|
13
|
+
currencyCode: currency ?? "USD",
|
|
14
|
+
locale: navigatorLanguage
|
|
15
|
+
});
|
|
15
16
|
};
|
|
16
17
|
export {
|
|
17
18
|
useFormattedPrice
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../hooks/use-formatted-price.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Use useFormattedPrice() hook to display prices with proper currency symbols and formatting. Pass in a price
|
|
5
|
-
"mappings": "AAIA,SAAS,sBAAsB;AAgBxB,MAAM,oBAAoB,CAC/B,OACA,aACG;AACH,QAAM,oBAAoB;AAAA,IACxB,MAAM,OAAO,UAAU;AAAA,IACvB;AAAA,EACF;
|
|
4
|
+
"sourcesContent": ["/**\n * Use useFormattedPrice() hook to display prices with proper currency symbols and formatting. Pass in a price in integer minor units (Stripe convention) and a currency code (e.g., 1999 and \"USD\") and it returns a formatted string like \"$19.99\".\n * @module\n */\nimport { formatAmount } from \"schemas/money\";\n\nimport { useClientValue } from \"./use-client-value\";\n\n/**\n * Use `useFormattedPrice` to format prices with proper currency and locale.\n * @returns A formatted price string based on the price and currency code. It\n * already takes into account the user's locale/browser.\n * @example\n * ```tsx\n * import { useFormattedPrice } from \"canopy-sdk/hooks/use-formatted-price\";\n *\n * const originalPrice = 1999; // integer minor units\n * const originalPriceFormatted = useFormattedPrice(originalPrice, \"USD\");\n * // Display the formatted price\n * <p>{originalPriceFormatted}</p>;\n * ```\n */\nexport const useFormattedPrice = (\n price: number | null,\n currency: string | null,\n) => {\n const navigatorLanguage = useClientValue(\n () => window.navigator.language,\n \"en-US\",\n );\n\n // NOTE (Max, 2026-08-03): guard on null, not falsiness \u2014 0 is a real amount\n // (a free item), so `if (!price)` would render no price at all for it.\n if (price === null) {\n return null;\n }\n\n return formatAmount({\n amount: price,\n currencyCode: currency ?? \"USD\",\n locale: navigatorLanguage,\n });\n};\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,oBAAoB;AAE7B,SAAS,sBAAsB;AAgBxB,MAAM,oBAAoB,CAC/B,OACA,aACG;AACH,QAAM,oBAAoB;AAAA,IACxB,MAAM,OAAO,UAAU;AAAA,IACvB;AAAA,EACF;AAIA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,SAAO,aAAa;AAAA,IAClB,QAAQ;AAAA,IACR,cAAc,YAAY;AAAA,IAC1B,QAAQ;AAAA,EACV,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/money.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Money helpers for storefronts. All commerce amounts in canopy (variant
|
|
3
|
+
* prices, cart costs) are integer minor units, Stripe convention: 1999 =
|
|
4
|
+
* $19.99 USD, 1999 = ¥1999 JPY. Use formatAmount/useFormattedPrice for
|
|
5
|
+
* display and fromMinorUnitsToMajorUnits when handing amounts to analytics or third-party
|
|
6
|
+
* APIs that speak decimal money.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export { formatAmount, fromMinorUnitsToMajorUnits, fromMinorUnitsToMajorUnitsString, fromMajorUnitsToMinorUnits, } from "./_vendor/schemas/money";
|
package/money.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatAmount,
|
|
3
|
+
fromMinorUnitsToMajorUnits,
|
|
4
|
+
fromMinorUnitsToMajorUnitsString,
|
|
5
|
+
fromMajorUnitsToMinorUnits
|
|
6
|
+
} from "./_vendor/schemas/money.mjs";
|
|
7
|
+
export {
|
|
8
|
+
formatAmount,
|
|
9
|
+
fromMajorUnitsToMinorUnits,
|
|
10
|
+
fromMinorUnitsToMajorUnits,
|
|
11
|
+
fromMinorUnitsToMajorUnitsString
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=money.js.map
|
package/money.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../money.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Money helpers for storefronts. All commerce amounts in canopy (variant\n * prices, cart costs) are integer minor units, Stripe convention: 1999 =\n * $19.99 USD, 1999 = \u00A51999 JPY. Use formatAmount/useFormattedPrice for\n * display and fromMinorUnitsToMajorUnits when handing amounts to analytics or third-party\n * APIs that speak decimal money.\n * @module\n */\n// eslint-disable-next-line barrel-files/avoid-barrel-files, replo/no-export-from -- public SDK entrypoint: scaffolded sites cannot import workspace `schemas`, so this module is their only path to the money helpers.\nexport {\n formatAmount,\n fromMinorUnitsToMajorUnits,\n fromMinorUnitsToMajorUnitsString,\n fromMajorUnitsToMinorUnits,\n} from \"schemas/money\";\n"],
|
|
5
|
+
"mappings": "AASA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replohq/canopy-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Replo Canopy SDK — cart, analytics, data loaders, and editor runtime for agent-built Next.js sites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@tiptap/extension-text": "^2.25.0",
|
|
14
14
|
"@tiptap/extension-underline": "^2.25.0",
|
|
15
15
|
"@tiptap/pm": "^2.25.0",
|
|
16
|
+
"currency-codes": "^2.2.0",
|
|
16
17
|
"tiny-jsonc": "^1.0.2",
|
|
17
18
|
"uuid": "^11.1.0",
|
|
18
19
|
"zod": "^4.3.6"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AnalyticsProvider } from "../analytics/analytics-provider";
|
|
3
3
|
import { ReploFirstPartyPixel } from "../analytics/replo-first-party-pixel";
|
|
4
4
|
import { CartLoader } from "../cart/cart-loader";
|
|
@@ -18,10 +18,11 @@ async function ReploProvider({ children }) {
|
|
|
18
18
|
} catch {
|
|
19
19
|
checkoutProvider = "none";
|
|
20
20
|
}
|
|
21
|
+
const isDevServer = process.env.NODE_ENV === "development";
|
|
21
22
|
return /* @__PURE__ */ jsx(QueryProvider, { children: /* @__PURE__ */ jsxs(AnalyticsProvider, { checkoutProvider, children: [
|
|
22
23
|
/* @__PURE__ */ jsx(ReploFirstPartyPixel, {}),
|
|
23
|
-
/* @__PURE__ */ jsx(DocumentReadyBeacon, {}),
|
|
24
|
-
/* @__PURE__ */
|
|
24
|
+
isDevServer && /* @__PURE__ */ jsx(DocumentReadyBeacon, {}),
|
|
25
|
+
/* @__PURE__ */ jsx(CartLoader, { children: isDevServer ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
26
|
/* @__PURE__ */ jsx(NextErrorReporter, {}),
|
|
26
27
|
/* @__PURE__ */ jsxs(ClientErrorBoundary, { children: [
|
|
27
28
|
/* @__PURE__ */ jsx(LinkInterceptor, {}),
|
|
@@ -30,7 +31,7 @@ async function ReploProvider({ children }) {
|
|
|
30
31
|
/* @__PURE__ */ jsx(DesignLibraryPreview, {}),
|
|
31
32
|
children
|
|
32
33
|
] })
|
|
33
|
-
] })
|
|
34
|
+
] }) : children })
|
|
34
35
|
] }) });
|
|
35
36
|
}
|
|
36
37
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../providers/replo-provider.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { CheckoutProvider } from \"../lib/integration-utils\";\n\nimport { AnalyticsProvider } from \"../analytics/analytics-provider\";\nimport { ReploFirstPartyPixel } from \"../analytics/replo-first-party-pixel\";\nimport { CartLoader } from \"../cart/cart-loader\";\nimport { ClientErrorBoundary } from \"../editor/ClientErrorBoundary\";\nimport { DesignLibraryPreview } from \"../editor/design-library-preview/DesignLibraryPreview\";\nimport { DocumentReadyBeacon } from \"../editor/DocumentReadyBeacon\";\nimport LinkInterceptor from \"../editor/LinkInterceptor\";\nimport { NextErrorReporter } from \"../editor/NextErrorReporter\";\nimport PostHogRelay from \"../editor/posthog-relay\";\nimport { EditorSelection } from \"../editor/select-mode/EditorSelection\";\nimport { getCheckoutProvider } from \"../lib/integration-utils\";\nimport { QueryProvider } from \"./query-provider\";\n\nexport async function ReploProvider({ children }: React.PropsWithChildren) {\n // Server-resolved so the analytics layer can suppress checkout-funnel events\n // that Shopify's hosted checkout already reports. Defaults to \"none\" (events\n // fire) if the env can't be read, preserving prior behavior.\n let checkoutProvider: CheckoutProvider = \"none\";\n try {\n checkoutProvider = await getCheckoutProvider();\n } catch {\n checkoutProvider = \"none\";\n }\n\n return (\n <QueryProvider>\n <AnalyticsProvider checkoutProvider={checkoutProvider}>\n <ReploFirstPartyPixel />\n <DocumentReadyBeacon
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { CheckoutProvider } from \"../lib/integration-utils\";\n\nimport { AnalyticsProvider } from \"../analytics/analytics-provider\";\nimport { ReploFirstPartyPixel } from \"../analytics/replo-first-party-pixel\";\nimport { CartLoader } from \"../cart/cart-loader\";\nimport { ClientErrorBoundary } from \"../editor/ClientErrorBoundary\";\nimport { DesignLibraryPreview } from \"../editor/design-library-preview/DesignLibraryPreview\";\nimport { DocumentReadyBeacon } from \"../editor/DocumentReadyBeacon\";\nimport LinkInterceptor from \"../editor/LinkInterceptor\";\nimport { NextErrorReporter } from \"../editor/NextErrorReporter\";\nimport PostHogRelay from \"../editor/posthog-relay\";\nimport { EditorSelection } from \"../editor/select-mode/EditorSelection\";\nimport { getCheckoutProvider } from \"../lib/integration-utils\";\nimport { QueryProvider } from \"./query-provider\";\n\nexport async function ReploProvider({ children }: React.PropsWithChildren) {\n // Server-resolved so the analytics layer can suppress checkout-funnel events\n // that Shopify's hosted checkout already reports. Defaults to \"none\" (events\n // fire) if the env can't be read, preserving prior behavior.\n let checkoutProvider: CheckoutProvider = \"none\";\n try {\n checkoutProvider = await getCheckoutProvider();\n } catch {\n checkoutProvider = \"none\";\n }\n\n // The editor only embeds dev servers (`next dev`), so editor-integration components render there only \u2014 production builds ship none of them and behave like plain Next apps.\n const isDevServer = process.env.NODE_ENV === \"development\";\n\n return (\n <QueryProvider>\n <AnalyticsProvider checkoutProvider={checkoutProvider}>\n <ReploFirstPartyPixel />\n {isDevServer && <DocumentReadyBeacon />}\n <CartLoader>\n {isDevServer ? (\n <>\n {/* NOTE (Max, 2026-06-08): Outside ClientErrorBoundary on purpose \u2014 when\n the boundary catches a runtime error it swaps its children for a\n neutral cover, which would unmount the reporter and freeze it in the\n error state. It must stay mounted to observe Next's overlay across\n error <-> recover. */}\n <NextErrorReporter />\n <ClientErrorBoundary>\n <LinkInterceptor />\n <PostHogRelay />\n <EditorSelection />\n <DesignLibraryPreview />\n {children}\n </ClientErrorBoundary>\n </>\n ) : (\n children\n )}\n </CartLoader>\n </AnalyticsProvider>\n </QueryProvider>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAgCQ,SAII,UAJJ,KAWM,YAXN;AA9BR,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,OAAO,qBAAqB;AAC5B,SAAS,yBAAyB;AAClC,OAAO,kBAAkB;AACzB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAE9B,eAAsB,cAAc,EAAE,SAAS,GAA4B;AAIzE,MAAI,mBAAqC;AACzC,MAAI;AACF,uBAAmB,MAAM,oBAAoB;AAAA,EAC/C,QAAQ;AACN,uBAAmB;AAAA,EACrB;AAGA,QAAM,cAAc,QAAQ,IAAI,aAAa;AAE7C,SACE,oBAAC,iBACC,+BAAC,qBAAkB,kBACjB;AAAA,wBAAC,wBAAqB;AAAA,IACrB,eAAe,oBAAC,uBAAoB;AAAA,IACrC,oBAAC,cACE,wBACC,iCAME;AAAA,0BAAC,qBAAkB;AAAA,MACnB,qBAAC,uBACC;AAAA,4BAAC,mBAAgB;AAAA,QACjB,oBAAC,gBAAa;AAAA,QACd,oBAAC,mBAAgB;AAAA,QACjB,oBAAC,wBAAqB;AAAA,QACrB;AAAA,SACH;AAAA,OACF,IAEA,UAEJ;AAAA,KACF,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { isObjectLike_default, baseGetTag_default, isArray_default } from './chunk-FNTGY7I5.mjs';
|
|
2
2
|
|
|
3
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isNumber.js
|
|
4
|
-
var numberTag = "[object Number]";
|
|
5
|
-
function isNumber(value) {
|
|
6
|
-
return typeof value == "number" || isObjectLike_default(value) && baseGetTag_default(value) == numberTag;
|
|
7
|
-
}
|
|
8
|
-
var isNumber_default = isNumber;
|
|
9
|
-
|
|
10
3
|
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js
|
|
11
4
|
function isObject(value) {
|
|
12
5
|
var type = typeof value;
|
|
@@ -14,6 +7,13 @@ function isObject(value) {
|
|
|
14
7
|
}
|
|
15
8
|
var isObject_default = isObject;
|
|
16
9
|
|
|
10
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isNumber.js
|
|
11
|
+
var numberTag = "[object Number]";
|
|
12
|
+
function isNumber(value) {
|
|
13
|
+
return typeof value == "number" || isObjectLike_default(value) && baseGetTag_default(value) == numberTag;
|
|
14
|
+
}
|
|
15
|
+
var isNumber_default = isNumber;
|
|
16
|
+
|
|
17
17
|
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
|
|
18
18
|
var stringTag = "[object String]";
|
|
19
19
|
function isString(value) {
|