@kotao/storefront 0.2.4 → 0.2.6
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/README.md +50 -2
- package/dist/bridge-ZKbKqgFd.d.ts +239 -0
- package/dist/cart-documents-BLavRDiu.d.ts +89 -0
- package/dist/cart-documents.d.ts +1 -2
- package/dist/cart-documents.js +1 -1
- package/dist/{chunk-M7BPQ54D.js → chunk-2MRB6SMP.js} +4 -3
- package/dist/chunk-2MRB6SMP.js.map +1 -0
- package/dist/chunk-CKGI3Y7L.js +19 -0
- package/dist/chunk-CKGI3Y7L.js.map +1 -0
- package/dist/{chunk-4TEFGD42.js → chunk-EG34HLSX.js} +209 -162
- package/dist/chunk-EG34HLSX.js.map +1 -0
- package/dist/chunk-O6YZEY7X.js +1382 -0
- package/dist/chunk-O6YZEY7X.js.map +1 -0
- package/dist/{chunk-7MTCGXIG.js → chunk-R4N565GX.js} +8 -4
- package/dist/chunk-R4N565GX.js.map +1 -0
- package/dist/{chunk-XMTWFJCZ.js → chunk-RFM27BKZ.js} +31 -7
- package/dist/chunk-RFM27BKZ.js.map +1 -0
- package/dist/{chunk-MYDKIJRH.js → chunk-SVMYFYIA.js} +2 -2
- package/dist/{chunk-MYDKIJRH.js.map → chunk-SVMYFYIA.js.map} +1 -1
- package/dist/{chunk-H3D7BAOL.js → chunk-VOTBNOWH.js} +21 -3
- package/dist/chunk-VOTBNOWH.js.map +1 -0
- package/dist/{chunk-PXVDVUFX.js → chunk-W74FGUZH.js} +10 -3
- package/dist/chunk-W74FGUZH.js.map +1 -0
- package/dist/{chunk-2IWNUDSZ.js → chunk-WNXI3MPM.js} +2 -2
- package/dist/chunk-WNXI3MPM.js.map +1 -0
- package/dist/chunk-XXNCFWXT.js +2118 -0
- package/dist/chunk-XXNCFWXT.js.map +1 -0
- package/dist/{client-bsiNPHBi.d.ts → client-CwOPPpFF.d.ts} +11 -1
- package/dist/{createCartHandler-C4RrPwSG.d.ts → createCartHandler-7DdKB-GF.d.ts} +1 -1
- package/dist/custom-css-Bl7Ur3-H.d.ts +6 -0
- package/dist/editor.d.ts +57 -104
- package/dist/editor.js +270 -1
- package/dist/editor.js.map +1 -1
- package/dist/events-react.d.ts +1 -1
- package/dist/events-react.js +1 -1
- package/dist/events.d.ts +3 -3
- package/dist/events.js +1 -1
- package/dist/{fetch-M3Y-fQrW.d.ts → fetch-Bq_cc8_G.d.ts} +5 -0
- package/dist/hydrogen-Bu7k0kE4.d.ts +259 -0
- package/dist/index.d.ts +74 -51
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/dist/react-router.d.ts +30 -9
- package/dist/react-router.js +16 -7
- package/dist/react-router.js.map +1 -1
- package/dist/react.d.ts +79 -11
- package/dist/react.js +279 -10
- package/dist/react.js.map +1 -1
- package/dist/{routing-sEonP93J.d.ts → routing-Bz3Cg0BW.d.ts} +36 -6
- package/dist/seo.d.ts +7 -4
- package/dist/seo.js +2 -2
- package/dist/settings.d.ts +14 -4
- package/dist/settings.js +2 -2
- package/dist/{shop-BJSvtmnV.d.ts → shop-CnrnSAJw.d.ts} +33 -6
- package/dist/{store-CtCWHI8H.d.ts → store-DO08fzJi.d.ts} +1 -1
- package/dist/storefront-api-types.d.ts +12 -0
- package/dist/{types-BDhHWZsP.d.ts → types-BkY0yET-.d.ts} +3 -3
- package/dist/{types-bcbQzx87.d.ts → types-DZX8ScsJ.d.ts} +2 -0
- package/package.json +4 -4
- package/dist/cart-documents-CwwRTvm8.d.ts +0 -21
- package/dist/chunk-2IWNUDSZ.js.map +0 -1
- package/dist/chunk-4TEFGD42.js.map +0 -1
- package/dist/chunk-7MTCGXIG.js.map +0 -1
- package/dist/chunk-H3D7BAOL.js.map +0 -1
- package/dist/chunk-M7BPQ54D.js.map +0 -1
- package/dist/chunk-PXVDVUFX.js.map +0 -1
- package/dist/chunk-PXZ737N3.js +0 -439
- package/dist/chunk-PXZ737N3.js.map +0 -1
- package/dist/chunk-XMTWFJCZ.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/seo/json-ld/common.ts","../src/seo/json-ld/product.ts","../src/seo/json-ld/local-business.ts","../src/seo/sitemap.ts","../src/seo/robots.ts","../src/seo/redirects.ts"],"names":[],"mappings":";AAGO,SAAS,QAAQ,GAAA,EAAsC;AAC5D,EAAA,MAAM,MAA+B,EAAC;AACtC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA,EAAG;AAC9C,IAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,KAAU,IAAA,IAAQ,UAAU,EAAA,EAAI;AAC3D,IAAA,IAAI,MAAM,OAAA,CAAQ,KAAK,CAAA,IAAK,KAAA,CAAM,WAAW,CAAA,EAAG;AAChD,IAAA,GAAA,CAAI,GAAG,CAAA,GAAI,KAAA;AAAA,EACb;AACA,EAAA,OAAO,GAAA;AACT;AAEA,IAAM,MAAA,GAAS,oBAAA;AAOR,SAAS,qBAAqB,KAAA,EAA0C;AAC7E,EAAA,OAAO;AAAA,IACL,UAAA,EAAY,MAAA;AAAA,IACZ,OAAA,EAAS,gBAAA;AAAA,IACT,eAAA,EAAiB,KAAA,CAAM,GAAA,CAAI,CAAC,MAAM,KAAA,MAAW;AAAA,MAC3C,OAAA,EAAS,UAAA;AAAA,MACT,UAAU,KAAA,GAAQ,CAAA;AAAA,MAClB,MAAM,IAAA,CAAK,IAAA;AAAA,MACX,MAAM,IAAA,CAAK;AAAA,KACb,CAAE;AAAA,GACJ;AACF;AASO,SAAS,mBAAmB,KAAA,EAAkC;AACnE,EAAA,OAAO,OAAA,CAAQ;AAAA,IACb,UAAA,EAAY,MAAA;AAAA,IACZ,OAAA,EAAS,cAAA;AAAA,IACT,MAAM,KAAA,CAAM,IAAA;AAAA,IACZ,KAAK,KAAA,CAAM,GAAA;AAAA,IACX,MAAM,KAAA,CAAM,IAAA;AAAA,IACZ,QAAQ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B,kBAAA;AAAA,MACA,EAAE,SAAA,EAAW,EAAE,IAAA,EAAK;AAAE,KACxB;AACA,IAAA,MAAA,GAAS,IAAA,CAAK,aAAa,MAAA,IAAU,IAAA;AAAA,EACvC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,eAAA,CAAgB,MAAM,MAAA,EAAQ,IAAA,EAAM,OAAO,CAAA;AACpD;AAMA,eAAsB,mBAAmB,OAAA,EAAuD;AAC9F,EAAA,IAAI,OAAA,CAAQ,QAAA,CAAS,MAAA,KAAW,GAAA,SAAY,OAAA,CAAQ,QAAA;AACpD,EAAA,MAAM,OAAO,IAAI,GAAA,CAAI,OAAA,CAAQ,OAAA,CAAQ,GAAG,CAAA,CAAE,QAAA;AAC1C,EAAA,MAAM,eAAA,GAAkB,QAAQ,MAAA,KAAW,MAAA,GAAY,EAAC,GAAI,EAAE,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAAO;AACrF,EAAA,OACG,MAAM,yBAAA,CAA0B,OAAA,CAAQ,YAAY,IAAA,EAAM,eAAe,KAAM,OAAA,CAAQ,QAAA;AAE5F","file":"chunk-PXVDVUFX.js","sourcesContent":["import type { JsonLd } from '../types'\n\n/** Drop undefined / null / '' / empty-array fields so JSON-LD never renders empty or null values. */\nexport function compact(obj: Record<string, unknown>): JsonLd {\n const out: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(obj)) {\n if (value === undefined || value === null || value === '') continue\n if (Array.isArray(value) && value.length === 0) continue\n out[key] = value\n }\n return out\n}\n\nconst SCHEMA = 'https://schema.org'\n\nexport interface BreadcrumbItem {\n readonly name: string\n readonly url: string\n}\n\nexport function breadcrumbListJsonLd(items: readonly BreadcrumbItem[]): JsonLd {\n return {\n '@context': SCHEMA,\n '@type': 'BreadcrumbList',\n itemListElement: items.map((item, index) => ({\n '@type': 'ListItem',\n position: index + 1,\n name: item.name,\n item: item.url,\n })),\n }\n}\n\nexport interface OrganizationInput {\n readonly name: string\n readonly url?: string\n readonly logo?: string\n readonly sameAs?: readonly string[]\n}\n\nexport function organizationJsonLd(input: OrganizationInput): JsonLd {\n return compact({\n '@context': SCHEMA,\n '@type': 'Organization',\n name: input.name,\n url: input.url,\n logo: input.logo,\n sameAs: input.sameAs,\n })\n}\n\nexport interface WebSiteInput {\n readonly name: string\n readonly url: string\n /** A URL template with `{search_term_string}` to enable the sitelinks search box. */\n readonly searchUrlTemplate?: string\n}\n\nexport function websiteJsonLd(input: WebSiteInput): JsonLd {\n return compact({\n '@context': SCHEMA,\n '@type': 'WebSite',\n name: input.name,\n url: input.url,\n potentialAction:\n input.searchUrlTemplate !== undefined\n ? {\n '@type': 'SearchAction',\n target: { '@type': 'EntryPoint', urlTemplate: input.searchUrlTemplate },\n 'query-input': 'required name=search_term_string',\n }\n : undefined,\n })\n}\n","import type { JsonLd } from '../types'\nimport { compact } from './common'\n\nexport interface OfferInput {\n readonly price: string | number\n readonly currency: string\n /** schema.org ItemAvailability short name, e.g. 'InStock' | 'OutOfStock' | 'PreOrder'. */\n readonly availability?: string\n readonly url?: string\n readonly sku?: string\n}\n\nexport interface ProductJsonLdInput {\n readonly name: string\n readonly description?: string\n readonly sku?: string\n readonly image?: string | readonly string[]\n readonly brand?: string\n readonly url?: string\n readonly offer?: OfferInput\n}\n\nfunction offerJsonLd(offer: OfferInput): JsonLd {\n return compact({\n '@type': 'Offer',\n price: String(offer.price),\n priceCurrency: offer.currency,\n availability:\n offer.availability !== undefined ? `https://schema.org/${offer.availability}` : undefined,\n url: offer.url,\n sku: offer.sku,\n })\n}\n\nexport function productJsonLd(input: ProductJsonLdInput): JsonLd {\n return compact({\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: input.name,\n description: input.description,\n sku: input.sku,\n image: input.image,\n brand: input.brand !== undefined ? { '@type': 'Brand', name: input.brand } : undefined,\n url: input.url,\n offers: input.offer !== undefined ? offerJsonLd(input.offer) : undefined,\n })\n}\n","import type { JsonLd } from '../types'\nimport { compact } from './common'\n\nexport interface AddressInput {\n readonly streetAddress?: string\n readonly locality?: string\n readonly region?: string\n readonly postalCode?: string\n readonly country?: string\n}\n\nexport interface GeoInput {\n readonly latitude: number\n readonly longitude: number\n}\n\nexport interface LocalBusinessInput {\n readonly name: string\n /** schema.org type, e.g. 'LocalBusiness' | 'Restaurant' | 'Store'. Defaults to 'LocalBusiness'. */\n readonly type?: string\n readonly url?: string\n readonly telephone?: string\n readonly priceRange?: string\n readonly image?: string | readonly string[]\n readonly address?: AddressInput\n readonly geo?: GeoInput\n /** schema.org openingHours strings, e.g. ['Mo-Fr 09:00-17:00', 'Sa 10:00-14:00']. */\n readonly openingHours?: readonly string[]\n /** Restaurant fields (used when type is 'Restaurant'). */\n readonly servesCuisine?: string | readonly string[]\n readonly menu?: string\n readonly acceptsReservations?: boolean\n}\n\nfunction addressJsonLd(address: AddressInput): JsonLd {\n return compact({\n '@type': 'PostalAddress',\n streetAddress: address.streetAddress,\n addressLocality: address.locality,\n addressRegion: address.region,\n postalCode: address.postalCode,\n addressCountry: address.country,\n })\n}\n\n/**\n * LocalBusiness JSON-LD — the brick-and-mortar / restaurant differentiator beyond Shopify's defaults\n * (the SDK table calls this out). `restaurantJsonLd` is the same builder pinned to `Restaurant`.\n */\nexport function localBusinessJsonLd(input: LocalBusinessInput): JsonLd {\n return compact({\n '@context': 'https://schema.org',\n '@type': input.type ?? 'LocalBusiness',\n name: input.name,\n url: input.url,\n telephone: input.telephone,\n priceRange: input.priceRange,\n image: input.image,\n address: input.address !== undefined ? addressJsonLd(input.address) : undefined,\n geo:\n input.geo !== undefined\n ? {\n '@type': 'GeoCoordinates',\n latitude: input.geo.latitude,\n longitude: input.geo.longitude,\n }\n : undefined,\n openingHours: input.openingHours,\n servesCuisine: input.servesCuisine,\n hasMenu: input.menu,\n acceptsReservations: input.acceptsReservations,\n })\n}\n\nexport function restaurantJsonLd(input: Omit<LocalBusinessInput, 'type'>): JsonLd {\n return localBusinessJsonLd({ ...input, type: 'Restaurant' })\n}\n","/**\n * sitemap.xml + sitemap-index factories. The entry source is injected (the caller resolves it from the\n * Storefront API or a search index — an open question, NOT decided here): build the entry list, then call\n * these. The index shape exists so large catalogs split into child sitemaps rather than one document.\n */\n\nexport type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never'\n\nexport interface SitemapEntry {\n readonly loc: string\n readonly lastmod?: string\n readonly changefreq?: ChangeFreq\n /** 0.0–1.0 (clamped). */\n readonly priority?: number\n}\n\nexport interface SitemapIndexEntry {\n readonly loc: string\n readonly lastmod?: string\n}\n\nconst XML_CONTENT_TYPE = 'application/xml; charset=utf-8'\n\nfunction escapeXml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n}\n\nexport function buildSitemapXml(entries: readonly SitemapEntry[]): string {\n const urls = entries\n .map((entry) => {\n const parts = [` <loc>${escapeXml(entry.loc)}</loc>`]\n if (entry.lastmod !== undefined)\n parts.push(` <lastmod>${escapeXml(entry.lastmod)}</lastmod>`)\n if (entry.changefreq !== undefined)\n parts.push(` <changefreq>${entry.changefreq}</changefreq>`)\n if (entry.priority !== undefined) {\n parts.push(\n ` <priority>${Math.max(0, Math.min(1, entry.priority)).toFixed(1)}</priority>`,\n )\n }\n return ` <url>\\n${parts.join('\\n')}\\n </url>`\n })\n .join('\\n')\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\\n${urls}\\n</urlset>\\n`\n}\n\nexport function buildSitemapIndexXml(sitemaps: readonly SitemapIndexEntry[]): string {\n const items = sitemaps\n .map((sitemap) => {\n const parts = [` <loc>${escapeXml(sitemap.loc)}</loc>`]\n if (sitemap.lastmod !== undefined)\n parts.push(` <lastmod>${escapeXml(sitemap.lastmod)}</lastmod>`)\n return ` <sitemap>\\n${parts.join('\\n')}\\n </sitemap>`\n })\n .join('\\n')\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\\n${items}\\n</sitemapindex>\\n`\n}\n\nexport function sitemapResponse(entries: readonly SitemapEntry[]): Response {\n return new Response(buildSitemapXml(entries), { headers: { 'content-type': XML_CONTENT_TYPE } })\n}\n\nexport function sitemapIndexResponse(sitemaps: readonly SitemapIndexEntry[]): Response {\n return new Response(buildSitemapIndexXml(sitemaps), {\n headers: { 'content-type': XML_CONTENT_TYPE },\n })\n}\n","/**\n * robots.txt factory. Non-production / preview deployments auto-disallow ALL crawling; production allows\n * and references the sitemap. `production` comes from the SDK's stage signal (context.env), NEVER the\n * request Host/URL (stage-pinned-config rule, AGENTS.md §Environments).\n */\nexport interface RobotsOptions {\n readonly production: boolean\n readonly sitemapUrl?: string\n /** Path prefixes to Disallow in production (e.g. /cart, /checkout — Shopify parity). */\n readonly disallow?: readonly string[]\n}\n\nexport function buildRobotsTxt(options: RobotsOptions): string {\n if (!options.production) {\n return 'User-agent: *\\nDisallow: /\\n'\n }\n const lines = ['User-agent: *', 'Allow: /']\n for (const path of options.disallow ?? []) lines.push(`Disallow: ${path}`)\n if (options.sitemapUrl !== undefined) lines.push(`Sitemap: ${options.sitemapUrl}`)\n return `${lines.join('\\n')}\\n`\n}\n\nexport function robotsResponse(options: RobotsOptions): Response {\n return new Response(buildRobotsTxt(options), {\n headers: { 'content-type': 'text/plain; charset=utf-8' },\n })\n}\n","import type { StorefrontClient } from '../storefront-client/client'\n\n/**\n * Slug-change 301 handler. The redirect store is owned elsewhere (catalog/storefront-API work); this\n * owns only the request-handling shape. The lookup is injected: given the current path, it returns the\n * canonical target (or null). A self-redirect (target === path) returns null to avoid an immediate loop.\n */\nexport type RedirectLookup = (path: string) => Promise<string | null> | string | null\n\nexport interface RedirectOptions {\n /** 301 (permanent, default) or 302 (temporary). */\n readonly status?: 301 | 302\n}\n\nexport interface StorefrontRedirectOptions extends RedirectOptions {\n readonly request: Request\n readonly response: Response\n readonly storefront: StorefrontClient\n}\n\nexport async function resolveRedirect(\n lookup: RedirectLookup,\n path: string,\n options: RedirectOptions = {},\n): Promise<Response | null> {\n const target = await lookup(path)\n if (target === null || target === '' || target === path) return null\n return new Response(null, {\n status: options.status ?? 301,\n headers: { location: target },\n })\n}\n\nexport const URL_REDIRECT_QUERY = `#graphql\n query UrlRedirect($path: String!) {\n urlRedirect(path: $path) {\n target\n }\n }\n`\n\n/**\n * Look up `path` in the storefront-api's url_redirects and, if found, return a 301 Response.\n * Returns null when there is no redirect, a self-redirect, or the lookup query fails (so the caller\n * falls through to its normal 404 — a lookup failure must never become a 500).\n */\nexport async function resolveStorefrontRedirect(\n storefront: StorefrontClient,\n path: string,\n options: RedirectOptions = {},\n): Promise<Response | null> {\n let target: string | null = null\n try {\n const data = await storefront.query<{ urlRedirect: { target: string } | null }>(\n URL_REDIRECT_QUERY,\n { variables: { path } },\n )\n target = data.urlRedirect?.target ?? null\n } catch {\n return null\n }\n return resolveRedirect(() => target, path, options)\n}\n\n/**\n * Hydrogen-compatible 404 redirect helper. It preserves the original response when there is no\n * matching URL redirect, mirroring the server.ts pattern used by Hydrogen demo stores.\n */\nexport async function storefrontRedirect(options: StorefrontRedirectOptions): Promise<Response> {\n if (options.response.status !== 404) return options.response\n const path = new URL(options.request.url).pathname\n const redirectOptions = options.status === undefined ? {} : { status: options.status }\n return (\n (await resolveStorefrontRedirect(options.storefront, path, redirectOptions)) ?? options.response\n )\n}\n"]}
|
package/dist/chunk-PXZ737N3.js
DELETED
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
// src/editor/bridge.ts
|
|
2
|
-
var HOST_SOURCE = "kotao:workspaces-editor";
|
|
3
|
-
var PREVIEW_SOURCE = "kotao:storefront-preview";
|
|
4
|
-
function isReservedSectionId(sectionId) {
|
|
5
|
-
return sectionId.startsWith("theme:");
|
|
6
|
-
}
|
|
7
|
-
function isRecord(value) {
|
|
8
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
-
}
|
|
10
|
-
function isSettings(value) {
|
|
11
|
-
return isRecord(value);
|
|
12
|
-
}
|
|
13
|
-
function isOptionalSettings(value) {
|
|
14
|
-
return value === void 0 || isSettings(value);
|
|
15
|
-
}
|
|
16
|
-
function isBlockId(value) {
|
|
17
|
-
return typeof value === "string" && value.length > 0;
|
|
18
|
-
}
|
|
19
|
-
function isResolvedBlock(value) {
|
|
20
|
-
return isRecord(value) && (value.id === void 0 || isBlockId(value.id)) && typeof value.type === "string" && isSettings(value.settings);
|
|
21
|
-
}
|
|
22
|
-
function isResolvedSection(value) {
|
|
23
|
-
if (!isRecord(value)) return false;
|
|
24
|
-
return typeof value.id === "string" && typeof value.type === "string" && isSettings(value.settings) && Array.isArray(value.blocks) && value.blocks.every(isResolvedBlock);
|
|
25
|
-
}
|
|
26
|
-
function isValuesDocument(value) {
|
|
27
|
-
return isRecord(value) && typeof value.shopId === "string" && isResolvedSectionArray(value.sections);
|
|
28
|
-
}
|
|
29
|
-
function isSettingOption(value) {
|
|
30
|
-
return isRecord(value) && typeof value.value === "string" && typeof value.label === "string";
|
|
31
|
-
}
|
|
32
|
-
function isOptionalString(value) {
|
|
33
|
-
return value === void 0 || typeof value === "string";
|
|
34
|
-
}
|
|
35
|
-
function isOptionalFiniteNumber(value) {
|
|
36
|
-
return value === void 0 || typeof value === "number" && Number.isFinite(value);
|
|
37
|
-
}
|
|
38
|
-
function isSettingInput(value) {
|
|
39
|
-
if (!isRecord(value) || typeof value.type !== "string" || typeof value.name !== "string" || typeof value.label !== "string") {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return isOptionalString(value.placeholder) && isOptionalString(value.helpText) && isOptionalString(value.unit) && isOptionalFiniteNumber(value.min) && isOptionalFiniteNumber(value.max) && isOptionalFiniteNumber(value.step) && (value.options === void 0 || Array.isArray(value.options) && value.options.every(isSettingOption));
|
|
43
|
-
}
|
|
44
|
-
function isBlockSchema(value) {
|
|
45
|
-
return isRecord(value) && typeof value.type === "string" && typeof value.label === "string" && Array.isArray(value.settings) && value.settings.every(isSettingInput);
|
|
46
|
-
}
|
|
47
|
-
function isSectionPresetBlock(value) {
|
|
48
|
-
return isRecord(value) && typeof value.type === "string" && isOptionalSettings(value.settings);
|
|
49
|
-
}
|
|
50
|
-
function isSectionPreset(value) {
|
|
51
|
-
return isRecord(value) && typeof value.name === "string" && isOptionalSettings(value.settings) && (value.blocks === void 0 || Array.isArray(value.blocks) && value.blocks.every(isSectionPresetBlock));
|
|
52
|
-
}
|
|
53
|
-
function isSectionSchema(value) {
|
|
54
|
-
return isRecord(value) && typeof value.type === "string" && typeof value.label === "string" && Array.isArray(value.settings) && value.settings.every(isSettingInput) && (value.blocks === void 0 || Array.isArray(value.blocks) && value.blocks.every(isBlockSchema)) && (value.presets === void 0 || Array.isArray(value.presets) && value.presets.every(isSectionPreset));
|
|
55
|
-
}
|
|
56
|
-
function isResolvedSectionArray(value) {
|
|
57
|
-
return Array.isArray(value) && value.every(isResolvedSection);
|
|
58
|
-
}
|
|
59
|
-
function isSectionSchemaRecord(value) {
|
|
60
|
-
return isRecord(value) && Object.values(value).every(isSectionSchema);
|
|
61
|
-
}
|
|
62
|
-
function isSettingInputArray(value) {
|
|
63
|
-
return Array.isArray(value) && value.every(isSettingInput);
|
|
64
|
-
}
|
|
65
|
-
function isValuesDocumentRecord(value) {
|
|
66
|
-
return isRecord(value) && Object.values(value).every(isValuesDocument);
|
|
67
|
-
}
|
|
68
|
-
function parseHostMessage(data, shopId) {
|
|
69
|
-
if (!isRecord(data) || data.source !== HOST_SOURCE || data.shopId !== shopId) return null;
|
|
70
|
-
switch (data.type) {
|
|
71
|
-
case "settings.patchSection":
|
|
72
|
-
return typeof data.sectionId === "string" && !isReservedSectionId(data.sectionId) && isSettings(data.settings) ? {
|
|
73
|
-
source: HOST_SOURCE,
|
|
74
|
-
type: "settings.patchSection",
|
|
75
|
-
shopId,
|
|
76
|
-
sectionId: data.sectionId,
|
|
77
|
-
settings: data.settings
|
|
78
|
-
} : null;
|
|
79
|
-
case "settings.patchGlobal":
|
|
80
|
-
return isSettings(data.settings) ? { source: HOST_SOURCE, type: "settings.patchGlobal", shopId, settings: data.settings } : null;
|
|
81
|
-
case "sections.insert":
|
|
82
|
-
return isResolvedSection(data.section) && !isReservedSectionId(data.section.id) ? {
|
|
83
|
-
source: HOST_SOURCE,
|
|
84
|
-
type: "sections.insert",
|
|
85
|
-
shopId,
|
|
86
|
-
section: data.section,
|
|
87
|
-
...typeof data.index === "number" ? { index: data.index } : {}
|
|
88
|
-
} : null;
|
|
89
|
-
case "sections.remove":
|
|
90
|
-
return typeof data.sectionId === "string" && !isReservedSectionId(data.sectionId) ? {
|
|
91
|
-
source: HOST_SOURCE,
|
|
92
|
-
type: "sections.remove",
|
|
93
|
-
shopId,
|
|
94
|
-
sectionId: data.sectionId
|
|
95
|
-
} : null;
|
|
96
|
-
case "sections.reorder":
|
|
97
|
-
return typeof data.sectionId === "string" && !isReservedSectionId(data.sectionId) && typeof data.index === "number" ? {
|
|
98
|
-
source: HOST_SOURCE,
|
|
99
|
-
type: "sections.reorder",
|
|
100
|
-
shopId,
|
|
101
|
-
sectionId: data.sectionId,
|
|
102
|
-
index: data.index
|
|
103
|
-
} : null;
|
|
104
|
-
case "settings.patchBlock":
|
|
105
|
-
return typeof data.sectionId === "string" && !isReservedSectionId(data.sectionId) && isBlockId(data.blockId) && isSettings(data.settings) ? {
|
|
106
|
-
source: HOST_SOURCE,
|
|
107
|
-
type: "settings.patchBlock",
|
|
108
|
-
shopId,
|
|
109
|
-
sectionId: data.sectionId,
|
|
110
|
-
blockId: data.blockId,
|
|
111
|
-
settings: data.settings
|
|
112
|
-
} : null;
|
|
113
|
-
case "blocks.insert":
|
|
114
|
-
return typeof data.sectionId === "string" && !isReservedSectionId(data.sectionId) && isResolvedBlock(data.block) ? {
|
|
115
|
-
source: HOST_SOURCE,
|
|
116
|
-
type: "blocks.insert",
|
|
117
|
-
shopId,
|
|
118
|
-
sectionId: data.sectionId,
|
|
119
|
-
block: data.block,
|
|
120
|
-
...typeof data.index === "number" ? { index: data.index } : {}
|
|
121
|
-
} : null;
|
|
122
|
-
case "blocks.remove":
|
|
123
|
-
return typeof data.sectionId === "string" && !isReservedSectionId(data.sectionId) && isBlockId(data.blockId) ? {
|
|
124
|
-
source: HOST_SOURCE,
|
|
125
|
-
type: "blocks.remove",
|
|
126
|
-
shopId,
|
|
127
|
-
sectionId: data.sectionId,
|
|
128
|
-
blockId: data.blockId
|
|
129
|
-
} : null;
|
|
130
|
-
case "blocks.reorder":
|
|
131
|
-
return typeof data.sectionId === "string" && !isReservedSectionId(data.sectionId) && isBlockId(data.blockId) && typeof data.index === "number" ? {
|
|
132
|
-
source: HOST_SOURCE,
|
|
133
|
-
type: "blocks.reorder",
|
|
134
|
-
shopId,
|
|
135
|
-
sectionId: data.sectionId,
|
|
136
|
-
blockId: data.blockId,
|
|
137
|
-
index: data.index
|
|
138
|
-
} : null;
|
|
139
|
-
case "template.replace":
|
|
140
|
-
return typeof data.handle === "string" && isValuesDocument(data.document) ? {
|
|
141
|
-
source: HOST_SOURCE,
|
|
142
|
-
type: "template.replace",
|
|
143
|
-
shopId,
|
|
144
|
-
handle: data.handle,
|
|
145
|
-
document: data.document
|
|
146
|
-
} : null;
|
|
147
|
-
case "sectionGroup.replace":
|
|
148
|
-
return typeof data.handle === "string" && data.handle.trim() !== "" && isValuesDocument(data.document) ? {
|
|
149
|
-
source: HOST_SOURCE,
|
|
150
|
-
type: "sectionGroup.replace",
|
|
151
|
-
shopId,
|
|
152
|
-
handle: data.handle,
|
|
153
|
-
document: data.document
|
|
154
|
-
} : null;
|
|
155
|
-
default:
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function parsePreviewSelection(data, shopId) {
|
|
160
|
-
if (!isRecord(data) || data.source !== PREVIEW_SOURCE || data.shopId !== shopId) return null;
|
|
161
|
-
if (data.type !== "section.select" || typeof data.sectionId !== "string") return null;
|
|
162
|
-
if (data.section !== void 0 && !isResolvedSection(data.section)) return null;
|
|
163
|
-
if (data.sections !== void 0 && !isResolvedSectionArray(data.sections)) return null;
|
|
164
|
-
if (data.schema !== void 0 && !isSectionSchema(data.schema)) return null;
|
|
165
|
-
if (data.schemas !== void 0 && !isSectionSchemaRecord(data.schemas)) return null;
|
|
166
|
-
return {
|
|
167
|
-
source: PREVIEW_SOURCE,
|
|
168
|
-
type: "section.select",
|
|
169
|
-
shopId,
|
|
170
|
-
sectionId: data.sectionId,
|
|
171
|
-
...data.section !== void 0 ? { section: data.section } : {},
|
|
172
|
-
...data.sections !== void 0 ? { sections: data.sections } : {},
|
|
173
|
-
...data.schema !== void 0 ? { schema: data.schema } : {},
|
|
174
|
-
...data.schemas !== void 0 ? { schemas: data.schemas } : {}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function parsePreviewReady(data, shopId) {
|
|
178
|
-
if (!isRecord(data) || data.source !== PREVIEW_SOURCE || data.shopId !== shopId) return null;
|
|
179
|
-
if (data.type !== "editor.ready" || !isResolvedSectionArray(data.sections)) return null;
|
|
180
|
-
if (data.schemas !== void 0 && !isSectionSchemaRecord(data.schemas)) return null;
|
|
181
|
-
if (data.globalInputs !== void 0 && !isSettingInputArray(data.globalInputs)) return null;
|
|
182
|
-
if (data.templates !== void 0 && !isValuesDocumentRecord(data.templates)) return null;
|
|
183
|
-
if (data.sectionGroups !== void 0 && !isValuesDocumentRecord(data.sectionGroups)) return null;
|
|
184
|
-
return {
|
|
185
|
-
source: PREVIEW_SOURCE,
|
|
186
|
-
type: "editor.ready",
|
|
187
|
-
shopId,
|
|
188
|
-
sections: data.sections,
|
|
189
|
-
...data.schemas !== void 0 ? { schemas: data.schemas } : {},
|
|
190
|
-
...data.globalInputs !== void 0 ? { globalInputs: data.globalInputs } : {},
|
|
191
|
-
...data.templates !== void 0 ? { templates: data.templates } : {},
|
|
192
|
-
...data.sectionGroups !== void 0 ? { sectionGroups: data.sectionGroups } : {}
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function postHostMessage(target, previewOrigin, message) {
|
|
196
|
-
target.postMessage(message, previewOrigin);
|
|
197
|
-
}
|
|
198
|
-
function createStorefrontEditorBridge({
|
|
199
|
-
adminOrigin,
|
|
200
|
-
globalInputs,
|
|
201
|
-
schemas,
|
|
202
|
-
sectionGroups,
|
|
203
|
-
shopId,
|
|
204
|
-
store,
|
|
205
|
-
target,
|
|
206
|
-
templates,
|
|
207
|
-
transport
|
|
208
|
-
}) {
|
|
209
|
-
const onMessage = (event) => {
|
|
210
|
-
if (event.origin !== adminOrigin) return;
|
|
211
|
-
if (event.source !== void 0 && event.source !== null && event.source !== target) return;
|
|
212
|
-
const message = parseHostMessage(event.data, shopId);
|
|
213
|
-
if (message === null) return;
|
|
214
|
-
switch (message.type) {
|
|
215
|
-
case "settings.patchSection":
|
|
216
|
-
store.patchSection(message.sectionId, message.settings);
|
|
217
|
-
break;
|
|
218
|
-
case "settings.patchGlobal":
|
|
219
|
-
store.patchGlobal(message.settings);
|
|
220
|
-
break;
|
|
221
|
-
case "sections.insert":
|
|
222
|
-
store.insertSection(message.section, message.index);
|
|
223
|
-
break;
|
|
224
|
-
case "sections.remove":
|
|
225
|
-
store.removeSection(message.sectionId);
|
|
226
|
-
break;
|
|
227
|
-
case "sections.reorder":
|
|
228
|
-
store.moveSection(message.sectionId, message.index);
|
|
229
|
-
break;
|
|
230
|
-
case "settings.patchBlock":
|
|
231
|
-
store.patchBlock(message.sectionId, message.blockId, message.settings);
|
|
232
|
-
break;
|
|
233
|
-
case "blocks.insert":
|
|
234
|
-
store.insertBlock(message.sectionId, message.block, message.index);
|
|
235
|
-
break;
|
|
236
|
-
case "blocks.remove":
|
|
237
|
-
store.removeBlock(message.sectionId, message.blockId);
|
|
238
|
-
break;
|
|
239
|
-
case "blocks.reorder":
|
|
240
|
-
store.moveBlock(message.sectionId, message.blockId, message.index);
|
|
241
|
-
break;
|
|
242
|
-
case "template.replace":
|
|
243
|
-
store.replaceSections(message.document.sections);
|
|
244
|
-
break;
|
|
245
|
-
case "sectionGroup.replace":
|
|
246
|
-
store.replaceSectionGroup(message.handle, message.document);
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
transport.addEventListener("message", onMessage);
|
|
251
|
-
return {
|
|
252
|
-
ready: () => {
|
|
253
|
-
const snapshot = store.getSnapshot();
|
|
254
|
-
const message = {
|
|
255
|
-
source: PREVIEW_SOURCE,
|
|
256
|
-
type: "editor.ready",
|
|
257
|
-
shopId,
|
|
258
|
-
sections: snapshot.sections,
|
|
259
|
-
...schemas !== void 0 ? { schemas } : {},
|
|
260
|
-
...globalInputs !== void 0 ? { globalInputs } : {},
|
|
261
|
-
...templates !== void 0 ? { templates } : {},
|
|
262
|
-
...sectionGroups !== void 0 ? { sectionGroups } : {}
|
|
263
|
-
};
|
|
264
|
-
target.postMessage(message, adminOrigin);
|
|
265
|
-
},
|
|
266
|
-
selectSection: (sectionId) => {
|
|
267
|
-
if (isReservedSectionId(sectionId)) return;
|
|
268
|
-
const snapshot = store.getSnapshot();
|
|
269
|
-
const section = snapshot.sections.find((candidate) => candidate.id === sectionId);
|
|
270
|
-
const schema = section !== void 0 ? schemas?.[section.type] : void 0;
|
|
271
|
-
const message = {
|
|
272
|
-
source: PREVIEW_SOURCE,
|
|
273
|
-
type: "section.select",
|
|
274
|
-
shopId,
|
|
275
|
-
sectionId,
|
|
276
|
-
...section !== void 0 ? { section } : {},
|
|
277
|
-
sections: snapshot.sections,
|
|
278
|
-
...schema !== void 0 ? { schema } : {},
|
|
279
|
-
...schemas !== void 0 ? { schemas } : {}
|
|
280
|
-
};
|
|
281
|
-
target.postMessage(message, adminOrigin);
|
|
282
|
-
},
|
|
283
|
-
dispose: () => {
|
|
284
|
-
transport.removeEventListener("message", onMessage);
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
function createStorefrontEditorHostBridge({
|
|
289
|
-
onReady,
|
|
290
|
-
onSelectSection,
|
|
291
|
-
previewOrigin,
|
|
292
|
-
shopId,
|
|
293
|
-
target,
|
|
294
|
-
transport
|
|
295
|
-
}) {
|
|
296
|
-
const onMessage = (event) => {
|
|
297
|
-
if (event.origin !== previewOrigin) return;
|
|
298
|
-
if (event.source !== void 0 && event.source !== null && event.source !== target) return;
|
|
299
|
-
const ready = parsePreviewReady(event.data, shopId);
|
|
300
|
-
if (ready !== null) {
|
|
301
|
-
onReady?.({
|
|
302
|
-
sections: ready.sections,
|
|
303
|
-
...ready.schemas !== void 0 ? { schemas: ready.schemas } : {},
|
|
304
|
-
...ready.globalInputs !== void 0 ? { globalInputs: ready.globalInputs } : {},
|
|
305
|
-
...ready.templates !== void 0 ? { templates: ready.templates } : {},
|
|
306
|
-
...ready.sectionGroups !== void 0 ? { sectionGroups: ready.sectionGroups } : {}
|
|
307
|
-
});
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const message = parsePreviewSelection(event.data, shopId);
|
|
311
|
-
if (message === null || isReservedSectionId(message.sectionId)) return;
|
|
312
|
-
onSelectSection({
|
|
313
|
-
sectionId: message.sectionId,
|
|
314
|
-
...message.section !== void 0 ? { section: message.section } : {},
|
|
315
|
-
...message.sections !== void 0 ? { sections: message.sections } : {},
|
|
316
|
-
...message.schema !== void 0 ? { schema: message.schema } : {},
|
|
317
|
-
...message.schemas !== void 0 ? { schemas: message.schemas } : {}
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
transport.addEventListener("message", onMessage);
|
|
321
|
-
return {
|
|
322
|
-
patchSection: (sectionId, settings) => {
|
|
323
|
-
if (isReservedSectionId(sectionId)) return;
|
|
324
|
-
postHostMessage(target, previewOrigin, {
|
|
325
|
-
source: HOST_SOURCE,
|
|
326
|
-
type: "settings.patchSection",
|
|
327
|
-
shopId,
|
|
328
|
-
sectionId,
|
|
329
|
-
settings
|
|
330
|
-
});
|
|
331
|
-
},
|
|
332
|
-
patchGlobal: (settings) => {
|
|
333
|
-
postHostMessage(target, previewOrigin, {
|
|
334
|
-
source: HOST_SOURCE,
|
|
335
|
-
type: "settings.patchGlobal",
|
|
336
|
-
shopId,
|
|
337
|
-
settings
|
|
338
|
-
});
|
|
339
|
-
},
|
|
340
|
-
insertSection: (section, index) => {
|
|
341
|
-
if (isReservedSectionId(section.id)) return;
|
|
342
|
-
postHostMessage(target, previewOrigin, {
|
|
343
|
-
source: HOST_SOURCE,
|
|
344
|
-
type: "sections.insert",
|
|
345
|
-
shopId,
|
|
346
|
-
section,
|
|
347
|
-
...index !== void 0 ? { index } : {}
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
removeSection: (sectionId) => {
|
|
351
|
-
if (isReservedSectionId(sectionId)) return;
|
|
352
|
-
postHostMessage(target, previewOrigin, {
|
|
353
|
-
source: HOST_SOURCE,
|
|
354
|
-
type: "sections.remove",
|
|
355
|
-
shopId,
|
|
356
|
-
sectionId
|
|
357
|
-
});
|
|
358
|
-
},
|
|
359
|
-
reorderSection: (sectionId, index) => {
|
|
360
|
-
if (isReservedSectionId(sectionId)) return;
|
|
361
|
-
postHostMessage(target, previewOrigin, {
|
|
362
|
-
source: HOST_SOURCE,
|
|
363
|
-
type: "sections.reorder",
|
|
364
|
-
shopId,
|
|
365
|
-
sectionId,
|
|
366
|
-
index
|
|
367
|
-
});
|
|
368
|
-
},
|
|
369
|
-
patchBlock: (sectionId, blockId, settings) => {
|
|
370
|
-
if (isReservedSectionId(sectionId)) return;
|
|
371
|
-
postHostMessage(target, previewOrigin, {
|
|
372
|
-
source: HOST_SOURCE,
|
|
373
|
-
type: "settings.patchBlock",
|
|
374
|
-
shopId,
|
|
375
|
-
sectionId,
|
|
376
|
-
blockId,
|
|
377
|
-
settings
|
|
378
|
-
});
|
|
379
|
-
},
|
|
380
|
-
insertBlock: (sectionId, block, index) => {
|
|
381
|
-
if (isReservedSectionId(sectionId)) return;
|
|
382
|
-
postHostMessage(target, previewOrigin, {
|
|
383
|
-
source: HOST_SOURCE,
|
|
384
|
-
type: "blocks.insert",
|
|
385
|
-
shopId,
|
|
386
|
-
sectionId,
|
|
387
|
-
block,
|
|
388
|
-
...index !== void 0 ? { index } : {}
|
|
389
|
-
});
|
|
390
|
-
},
|
|
391
|
-
removeBlock: (sectionId, blockId) => {
|
|
392
|
-
if (isReservedSectionId(sectionId)) return;
|
|
393
|
-
postHostMessage(target, previewOrigin, {
|
|
394
|
-
source: HOST_SOURCE,
|
|
395
|
-
type: "blocks.remove",
|
|
396
|
-
shopId,
|
|
397
|
-
sectionId,
|
|
398
|
-
blockId
|
|
399
|
-
});
|
|
400
|
-
},
|
|
401
|
-
reorderBlock: (sectionId, blockId, index) => {
|
|
402
|
-
if (isReservedSectionId(sectionId)) return;
|
|
403
|
-
postHostMessage(target, previewOrigin, {
|
|
404
|
-
source: HOST_SOURCE,
|
|
405
|
-
type: "blocks.reorder",
|
|
406
|
-
shopId,
|
|
407
|
-
sectionId,
|
|
408
|
-
blockId,
|
|
409
|
-
index
|
|
410
|
-
});
|
|
411
|
-
},
|
|
412
|
-
replaceTemplate: (handle, document) => {
|
|
413
|
-
postHostMessage(target, previewOrigin, {
|
|
414
|
-
source: HOST_SOURCE,
|
|
415
|
-
type: "template.replace",
|
|
416
|
-
shopId,
|
|
417
|
-
handle,
|
|
418
|
-
document
|
|
419
|
-
});
|
|
420
|
-
},
|
|
421
|
-
replaceSectionGroup: (handle, document) => {
|
|
422
|
-
if (handle.trim() === "") return;
|
|
423
|
-
postHostMessage(target, previewOrigin, {
|
|
424
|
-
source: HOST_SOURCE,
|
|
425
|
-
type: "sectionGroup.replace",
|
|
426
|
-
shopId,
|
|
427
|
-
handle,
|
|
428
|
-
document
|
|
429
|
-
});
|
|
430
|
-
},
|
|
431
|
-
dispose: () => {
|
|
432
|
-
transport.removeEventListener("message", onMessage);
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export { createStorefrontEditorBridge, createStorefrontEditorHostBridge };
|
|
438
|
-
//# sourceMappingURL=chunk-PXZ737N3.js.map
|
|
439
|
-
//# sourceMappingURL=chunk-PXZ737N3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/editor/bridge.ts"],"names":[],"mappings":";AAGA,IAAM,WAAA,GAAc,yBAAA;AACpB,IAAM,cAAA,GAAiB,0BAAA;AAgOvB,SAAS,oBAAoB,SAAA,EAA4B;AACvD,EAAA,OAAO,SAAA,CAAU,WAAW,QAAQ,CAAA;AACtC;AAEA,SAAS,SAAS,KAAA,EAAkD;AAClE,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAEA,SAAS,WAAW,KAAA,EAA2C;AAC7D,EAAA,OAAO,SAAS,KAAK,CAAA;AACvB;AAEA,SAAS,mBAAmB,KAAA,EAAuD;AACjF,EAAA,OAAO,KAAA,KAAU,MAAA,IAAa,UAAA,CAAW,KAAK,CAAA;AAChD;AAEA,SAAS,UAAU,KAAA,EAAiC;AAClD,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,MAAA,GAAS,CAAA;AACrD;AAEA,SAAS,gBAAgB,KAAA,EAAwC;AAC/D,EAAA,OACE,SAAS,KAAK,CAAA,KACb,KAAA,CAAM,EAAA,KAAO,UAAa,SAAA,CAAU,KAAA,CAAM,EAAE,CAAA,CAAA,IAC7C,OAAO,KAAA,CAAM,IAAA,KAAS,QAAA,IACtB,UAAA,CAAW,MAAM,QAAQ,CAAA;AAE7B;AAEA,SAAS,kBAAkB,KAAA,EAA0C;AACnE,EAAA,IAAI,CAAC,QAAA,CAAS,KAAK,CAAA,EAAG,OAAO,KAAA;AAC7B,EAAA,OACE,OAAO,MAAM,EAAA,KAAO,QAAA,IACpB,OAAO,KAAA,CAAM,IAAA,KAAS,YACtB,UAAA,CAAW,KAA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W,OAAA,EAAS,KAAA,KAAU;AAC3C,MAAA,IAAI,mBAAA,CAAoB,SAAS,CAAA,EAAG;AACpC,MAAA,eAAA,CAAgB,QAAQ,aAAA,EAAe;AAAA,QACrC,MAAA,EAAQ,WAAA;AAAA,QACR,IAAA,EAAM,gBAAA;AAAA,QACN,MAAA;AAAA,QACA,SAAA;AAAA,QACA,OAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,IACH,CAAA;AAAA,IACA,eAAA,EAAiB,CAAC,MAAA,EAAQ,QAAA,KAAa;AACrC,MAAA,eAAA,CAAgB,QAAQ,aAAA,EAAe;AAAA,QACrC,MAAA,EAAQ,WAAA;AAAA,QACR,IAAA,EAAM,kBAAA;AAAA,QACN,MAAA;AAAA,QACA,MAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,IACH,CAAA;AAAA,IACA,mBAAA,EAAqB,CAAC,MAAA,EAAQ,QAAA,KAAa;AACzC,MAAA,IAAI,MAAA,CAAO,IAAA,EAAK,KAAM,EAAA,EAAI;AAC1B,MAAA,eAAA,CAAgB,QAAQ,aAAA,EAAe;AAAA,QACrC,MAAA,EAAQ,WAAA;AAAA,QACR,IAAA,EAAM,sBAAA;AAAA,QACN,MAAA;AAAA,QACA,MAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,IACH,CAAA;AAAA,IACA,SAAS,MAAM;AACb,MAAA,SAAA,CAAU,mBAAA,CAAoB,WAAW,SAAS,CAAA;AAAA,IACpD;AAAA,GACF;AACF","file":"chunk-PXZ737N3.js","sourcesContent":["import type { ThemeSettingsStore } from '../settings/store'\nimport type { ResolvedBlock, ResolvedSection, ResolvedSettings } from '../settings/types'\n\nconst HOST_SOURCE = 'kotao:workspaces-editor'\nconst PREVIEW_SOURCE = 'kotao:storefront-preview'\n\nexport interface StorefrontEditorMessageTarget {\n postMessage(message: unknown, targetOrigin: string): void\n}\n\nexport interface StorefrontEditorMessageEvent {\n readonly origin: string\n readonly data: unknown\n readonly source?: StorefrontEditorMessageTarget | null\n}\n\nexport interface StorefrontEditorMessageSource {\n addEventListener(type: 'message', listener: (event: StorefrontEditorMessageEvent) => void): void\n removeEventListener(\n type: 'message',\n listener: (event: StorefrontEditorMessageEvent) => void,\n ): void\n}\n\nexport interface StorefrontEditorBridge {\n ready(): void\n selectSection(sectionId: string): void\n dispose(): void\n}\n\nexport interface StorefrontEditorSettingOption {\n readonly value: string\n readonly label: string\n}\n\nexport interface StorefrontEditorSettingInput {\n readonly type: string\n readonly name: string\n readonly label: string\n readonly defaultValue?: unknown\n readonly placeholder?: string\n readonly helpText?: string\n readonly options?: readonly StorefrontEditorSettingOption[]\n readonly min?: number\n readonly max?: number\n readonly step?: number\n readonly unit?: string\n}\n\nexport interface StorefrontEditorBlockSchema {\n readonly type: string\n readonly label: string\n readonly settings: readonly StorefrontEditorSettingInput[]\n}\n\nexport interface StorefrontEditorSectionPresetBlock {\n readonly type: string\n readonly settings?: ResolvedSettings\n}\n\nexport interface StorefrontEditorSectionPreset {\n readonly name: string\n readonly settings?: ResolvedSettings\n readonly blocks?: readonly StorefrontEditorSectionPresetBlock[]\n}\n\nexport interface StorefrontEditorSectionSchema {\n readonly type: string\n readonly label: string\n readonly settings: readonly StorefrontEditorSettingInput[]\n readonly blocks?: readonly StorefrontEditorBlockSchema[]\n readonly presets?: readonly StorefrontEditorSectionPreset[]\n}\n\nexport interface StorefrontEditorSelection {\n readonly sectionId: string\n readonly section?: ResolvedSection\n readonly sections?: readonly ResolvedSection[]\n readonly schema?: StorefrontEditorSectionSchema\n readonly schemas?: Readonly<Record<string, StorefrontEditorSectionSchema>>\n}\n\nexport interface StorefrontEditorValuesDocument {\n readonly shopId: string\n readonly sections: readonly ResolvedSection[]\n}\n\nexport interface StorefrontEditorReady {\n readonly sections: readonly ResolvedSection[]\n readonly schemas?: Readonly<Record<string, StorefrontEditorSectionSchema>>\n readonly globalInputs?: readonly StorefrontEditorSettingInput[]\n readonly templates?: Readonly<Record<string, StorefrontEditorValuesDocument>>\n readonly sectionGroups?: Readonly<Record<string, StorefrontEditorValuesDocument>>\n}\n\nexport interface StorefrontEditorHostBridge {\n patchSection(sectionId: string, settings: ResolvedSettings): void\n patchGlobal(settings: ResolvedSettings): void\n insertSection(section: ResolvedSection, index?: number): void\n removeSection(sectionId: string): void\n reorderSection(sectionId: string, index: number): void\n patchBlock(sectionId: string, blockId: string, settings: ResolvedSettings): void\n insertBlock(sectionId: string, block: ResolvedBlock, index?: number): void\n removeBlock(sectionId: string, blockId: string): void\n reorderBlock(sectionId: string, blockId: string, index: number): void\n replaceTemplate(handle: string, document: StorefrontEditorValuesDocument): void\n replaceSectionGroup(handle: string, document: StorefrontEditorValuesDocument): void\n dispose(): void\n}\n\nexport interface CreateStorefrontEditorBridgeArgs {\n readonly adminOrigin: string\n readonly shopId: string\n readonly store: ThemeSettingsStore\n readonly schemas?: Readonly<Record<string, StorefrontEditorSectionSchema>>\n readonly globalInputs?: readonly StorefrontEditorSettingInput[]\n readonly templates?: Readonly<Record<string, StorefrontEditorValuesDocument>>\n readonly sectionGroups?: Readonly<Record<string, StorefrontEditorValuesDocument>>\n readonly transport: StorefrontEditorMessageSource\n readonly target: StorefrontEditorMessageTarget\n}\n\nexport interface CreateStorefrontEditorHostBridgeArgs {\n readonly onSelectSection: (selection: StorefrontEditorSelection) => void\n readonly onReady?: (ready: StorefrontEditorReady) => void\n readonly previewOrigin: string\n readonly shopId: string\n readonly transport: StorefrontEditorMessageSource\n readonly target: StorefrontEditorMessageTarget\n}\n\ntype HostMessage =\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'settings.patchSection'\n readonly shopId: string\n readonly sectionId: string\n readonly settings: ResolvedSettings\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'settings.patchGlobal'\n readonly shopId: string\n readonly settings: ResolvedSettings\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'sections.insert'\n readonly shopId: string\n readonly section: ResolvedSection\n readonly index?: number\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'sections.remove'\n readonly shopId: string\n readonly sectionId: string\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'sections.reorder'\n readonly shopId: string\n readonly sectionId: string\n readonly index: number\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'settings.patchBlock'\n readonly shopId: string\n readonly sectionId: string\n readonly blockId: string\n readonly settings: ResolvedSettings\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'blocks.insert'\n readonly shopId: string\n readonly sectionId: string\n readonly block: ResolvedBlock\n readonly index?: number\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'blocks.remove'\n readonly shopId: string\n readonly sectionId: string\n readonly blockId: string\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'blocks.reorder'\n readonly shopId: string\n readonly sectionId: string\n readonly blockId: string\n readonly index: number\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'template.replace'\n readonly shopId: string\n readonly handle: string\n readonly document: StorefrontEditorValuesDocument\n }\n | {\n readonly source: typeof HOST_SOURCE\n readonly type: 'sectionGroup.replace'\n readonly shopId: string\n readonly handle: string\n readonly document: StorefrontEditorValuesDocument\n }\n\ninterface PreviewSelectionMessage {\n readonly source: typeof PREVIEW_SOURCE\n readonly type: 'section.select'\n readonly shopId: string\n readonly sectionId: string\n readonly section?: ResolvedSection\n readonly sections?: readonly ResolvedSection[]\n readonly schema?: StorefrontEditorSectionSchema\n readonly schemas?: Readonly<Record<string, StorefrontEditorSectionSchema>>\n}\n\ninterface PreviewReadyMessage extends StorefrontEditorReady {\n readonly source: typeof PREVIEW_SOURCE\n readonly type: 'editor.ready'\n readonly shopId: string\n}\n\nfunction isReservedSectionId(sectionId: string): boolean {\n return sectionId.startsWith('theme:')\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction isSettings(value: unknown): value is ResolvedSettings {\n return isRecord(value)\n}\n\nfunction isOptionalSettings(value: unknown): value is ResolvedSettings | undefined {\n return value === undefined || isSettings(value)\n}\n\nfunction isBlockId(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0\n}\n\nfunction isResolvedBlock(value: unknown): value is ResolvedBlock {\n return (\n isRecord(value) &&\n (value.id === undefined || isBlockId(value.id)) &&\n typeof value.type === 'string' &&\n isSettings(value.settings)\n )\n}\n\nfunction isResolvedSection(value: unknown): value is ResolvedSection {\n if (!isRecord(value)) return false\n return (\n typeof value.id === 'string' &&\n typeof value.type === 'string' &&\n isSettings(value.settings) &&\n Array.isArray(value.blocks) &&\n value.blocks.every(isResolvedBlock)\n )\n}\n\nfunction isValuesDocument(value: unknown): value is StorefrontEditorValuesDocument {\n return (\n isRecord(value) && typeof value.shopId === 'string' && isResolvedSectionArray(value.sections)\n )\n}\n\nfunction isSettingOption(value: unknown): value is StorefrontEditorSettingOption {\n return isRecord(value) && typeof value.value === 'string' && typeof value.label === 'string'\n}\n\nfunction isOptionalString(value: unknown): value is string | undefined {\n return value === undefined || typeof value === 'string'\n}\n\nfunction isOptionalFiniteNumber(value: unknown): value is number | undefined {\n return value === undefined || (typeof value === 'number' && Number.isFinite(value))\n}\n\nfunction isSettingInput(value: unknown): value is StorefrontEditorSettingInput {\n if (\n !isRecord(value) ||\n typeof value.type !== 'string' ||\n typeof value.name !== 'string' ||\n typeof value.label !== 'string'\n ) {\n return false\n }\n\n return (\n isOptionalString(value.placeholder) &&\n isOptionalString(value.helpText) &&\n isOptionalString(value.unit) &&\n isOptionalFiniteNumber(value.min) &&\n isOptionalFiniteNumber(value.max) &&\n isOptionalFiniteNumber(value.step) &&\n (value.options === undefined ||\n (Array.isArray(value.options) && value.options.every(isSettingOption)))\n )\n}\n\nfunction isBlockSchema(value: unknown): value is StorefrontEditorBlockSchema {\n return (\n isRecord(value) &&\n typeof value.type === 'string' &&\n typeof value.label === 'string' &&\n Array.isArray(value.settings) &&\n value.settings.every(isSettingInput)\n )\n}\n\nfunction isSectionPresetBlock(value: unknown): value is StorefrontEditorSectionPresetBlock {\n return isRecord(value) && typeof value.type === 'string' && isOptionalSettings(value.settings)\n}\n\nfunction isSectionPreset(value: unknown): value is StorefrontEditorSectionPreset {\n return (\n isRecord(value) &&\n typeof value.name === 'string' &&\n isOptionalSettings(value.settings) &&\n (value.blocks === undefined ||\n (Array.isArray(value.blocks) && value.blocks.every(isSectionPresetBlock)))\n )\n}\n\nfunction isSectionSchema(value: unknown): value is StorefrontEditorSectionSchema {\n return (\n isRecord(value) &&\n typeof value.type === 'string' &&\n typeof value.label === 'string' &&\n Array.isArray(value.settings) &&\n value.settings.every(isSettingInput) &&\n (value.blocks === undefined ||\n (Array.isArray(value.blocks) && value.blocks.every(isBlockSchema))) &&\n (value.presets === undefined ||\n (Array.isArray(value.presets) && value.presets.every(isSectionPreset)))\n )\n}\n\nfunction isResolvedSectionArray(value: unknown): value is readonly ResolvedSection[] {\n return Array.isArray(value) && value.every(isResolvedSection)\n}\n\nfunction isSectionSchemaRecord(\n value: unknown,\n): value is Readonly<Record<string, StorefrontEditorSectionSchema>> {\n return isRecord(value) && Object.values(value).every(isSectionSchema)\n}\n\nfunction isSettingInputArray(value: unknown): value is readonly StorefrontEditorSettingInput[] {\n return Array.isArray(value) && value.every(isSettingInput)\n}\n\nfunction isValuesDocumentRecord(\n value: unknown,\n): value is Readonly<Record<string, StorefrontEditorValuesDocument>> {\n return isRecord(value) && Object.values(value).every(isValuesDocument)\n}\n\nfunction parseHostMessage(data: unknown, shopId: string): HostMessage | null {\n if (!isRecord(data) || data.source !== HOST_SOURCE || data.shopId !== shopId) return null\n\n switch (data.type) {\n case 'settings.patchSection':\n return typeof data.sectionId === 'string' &&\n !isReservedSectionId(data.sectionId) &&\n isSettings(data.settings)\n ? {\n source: HOST_SOURCE,\n type: 'settings.patchSection',\n shopId,\n sectionId: data.sectionId,\n settings: data.settings,\n }\n : null\n case 'settings.patchGlobal':\n return isSettings(data.settings)\n ? { source: HOST_SOURCE, type: 'settings.patchGlobal', shopId, settings: data.settings }\n : null\n case 'sections.insert':\n return isResolvedSection(data.section) && !isReservedSectionId(data.section.id)\n ? {\n source: HOST_SOURCE,\n type: 'sections.insert',\n shopId,\n section: data.section,\n ...(typeof data.index === 'number' ? { index: data.index } : {}),\n }\n : null\n case 'sections.remove':\n return typeof data.sectionId === 'string' && !isReservedSectionId(data.sectionId)\n ? {\n source: HOST_SOURCE,\n type: 'sections.remove',\n shopId,\n sectionId: data.sectionId,\n }\n : null\n case 'sections.reorder':\n return typeof data.sectionId === 'string' &&\n !isReservedSectionId(data.sectionId) &&\n typeof data.index === 'number'\n ? {\n source: HOST_SOURCE,\n type: 'sections.reorder',\n shopId,\n sectionId: data.sectionId,\n index: data.index,\n }\n : null\n case 'settings.patchBlock':\n return typeof data.sectionId === 'string' &&\n !isReservedSectionId(data.sectionId) &&\n isBlockId(data.blockId) &&\n isSettings(data.settings)\n ? {\n source: HOST_SOURCE,\n type: 'settings.patchBlock',\n shopId,\n sectionId: data.sectionId,\n blockId: data.blockId,\n settings: data.settings,\n }\n : null\n case 'blocks.insert':\n return typeof data.sectionId === 'string' &&\n !isReservedSectionId(data.sectionId) &&\n isResolvedBlock(data.block)\n ? {\n source: HOST_SOURCE,\n type: 'blocks.insert',\n shopId,\n sectionId: data.sectionId,\n block: data.block,\n ...(typeof data.index === 'number' ? { index: data.index } : {}),\n }\n : null\n case 'blocks.remove':\n return typeof data.sectionId === 'string' &&\n !isReservedSectionId(data.sectionId) &&\n isBlockId(data.blockId)\n ? {\n source: HOST_SOURCE,\n type: 'blocks.remove',\n shopId,\n sectionId: data.sectionId,\n blockId: data.blockId,\n }\n : null\n case 'blocks.reorder':\n return typeof data.sectionId === 'string' &&\n !isReservedSectionId(data.sectionId) &&\n isBlockId(data.blockId) &&\n typeof data.index === 'number'\n ? {\n source: HOST_SOURCE,\n type: 'blocks.reorder',\n shopId,\n sectionId: data.sectionId,\n blockId: data.blockId,\n index: data.index,\n }\n : null\n case 'template.replace':\n return typeof data.handle === 'string' && isValuesDocument(data.document)\n ? {\n source: HOST_SOURCE,\n type: 'template.replace',\n shopId,\n handle: data.handle,\n document: data.document,\n }\n : null\n case 'sectionGroup.replace':\n return typeof data.handle === 'string' &&\n data.handle.trim() !== '' &&\n isValuesDocument(data.document)\n ? {\n source: HOST_SOURCE,\n type: 'sectionGroup.replace',\n shopId,\n handle: data.handle,\n document: data.document,\n }\n : null\n default:\n return null\n }\n}\n\nfunction parsePreviewSelection(data: unknown, shopId: string): PreviewSelectionMessage | null {\n if (!isRecord(data) || data.source !== PREVIEW_SOURCE || data.shopId !== shopId) return null\n if (data.type !== 'section.select' || typeof data.sectionId !== 'string') return null\n if (data.section !== undefined && !isResolvedSection(data.section)) return null\n if (data.sections !== undefined && !isResolvedSectionArray(data.sections)) return null\n if (data.schema !== undefined && !isSectionSchema(data.schema)) return null\n if (data.schemas !== undefined && !isSectionSchemaRecord(data.schemas)) return null\n return {\n source: PREVIEW_SOURCE,\n type: 'section.select',\n shopId,\n sectionId: data.sectionId,\n ...(data.section !== undefined ? { section: data.section } : {}),\n ...(data.sections !== undefined ? { sections: data.sections } : {}),\n ...(data.schema !== undefined ? { schema: data.schema } : {}),\n ...(data.schemas !== undefined ? { schemas: data.schemas } : {}),\n }\n}\n\nfunction parsePreviewReady(data: unknown, shopId: string): PreviewReadyMessage | null {\n if (!isRecord(data) || data.source !== PREVIEW_SOURCE || data.shopId !== shopId) return null\n if (data.type !== 'editor.ready' || !isResolvedSectionArray(data.sections)) return null\n if (data.schemas !== undefined && !isSectionSchemaRecord(data.schemas)) return null\n if (data.globalInputs !== undefined && !isSettingInputArray(data.globalInputs)) return null\n if (data.templates !== undefined && !isValuesDocumentRecord(data.templates)) return null\n if (data.sectionGroups !== undefined && !isValuesDocumentRecord(data.sectionGroups)) return null\n return {\n source: PREVIEW_SOURCE,\n type: 'editor.ready',\n shopId,\n sections: data.sections,\n ...(data.schemas !== undefined ? { schemas: data.schemas } : {}),\n ...(data.globalInputs !== undefined ? { globalInputs: data.globalInputs } : {}),\n ...(data.templates !== undefined ? { templates: data.templates } : {}),\n ...(data.sectionGroups !== undefined ? { sectionGroups: data.sectionGroups } : {}),\n }\n}\n\nfunction postHostMessage(\n target: StorefrontEditorMessageTarget,\n previewOrigin: string,\n message: HostMessage,\n): void {\n target.postMessage(message, previewOrigin)\n}\n\nexport function createStorefrontEditorBridge({\n adminOrigin,\n globalInputs,\n schemas,\n sectionGroups,\n shopId,\n store,\n target,\n templates,\n transport,\n}: CreateStorefrontEditorBridgeArgs): StorefrontEditorBridge {\n const onMessage = (event: StorefrontEditorMessageEvent): void => {\n if (event.origin !== adminOrigin) return\n if (event.source !== undefined && event.source !== null && event.source !== target) return\n const message = parseHostMessage(event.data, shopId)\n if (message === null) return\n\n switch (message.type) {\n case 'settings.patchSection':\n store.patchSection(message.sectionId, message.settings)\n break\n case 'settings.patchGlobal':\n store.patchGlobal(message.settings)\n break\n case 'sections.insert':\n store.insertSection(message.section, message.index)\n break\n case 'sections.remove':\n store.removeSection(message.sectionId)\n break\n case 'sections.reorder':\n store.moveSection(message.sectionId, message.index)\n break\n case 'settings.patchBlock':\n store.patchBlock(message.sectionId, message.blockId, message.settings)\n break\n case 'blocks.insert':\n store.insertBlock(message.sectionId, message.block, message.index)\n break\n case 'blocks.remove':\n store.removeBlock(message.sectionId, message.blockId)\n break\n case 'blocks.reorder':\n store.moveBlock(message.sectionId, message.blockId, message.index)\n break\n case 'template.replace':\n store.replaceSections(message.document.sections)\n break\n case 'sectionGroup.replace':\n store.replaceSectionGroup(message.handle, message.document)\n break\n }\n }\n\n transport.addEventListener('message', onMessage)\n\n return {\n ready: () => {\n const snapshot = store.getSnapshot()\n const message: PreviewReadyMessage = {\n source: PREVIEW_SOURCE,\n type: 'editor.ready',\n shopId,\n sections: snapshot.sections,\n ...(schemas !== undefined ? { schemas } : {}),\n ...(globalInputs !== undefined ? { globalInputs } : {}),\n ...(templates !== undefined ? { templates } : {}),\n ...(sectionGroups !== undefined ? { sectionGroups } : {}),\n }\n target.postMessage(message, adminOrigin)\n },\n selectSection: (sectionId) => {\n if (isReservedSectionId(sectionId)) return\n const snapshot = store.getSnapshot()\n const section = snapshot.sections.find((candidate) => candidate.id === sectionId)\n const schema = section !== undefined ? schemas?.[section.type] : undefined\n const message: PreviewSelectionMessage = {\n source: PREVIEW_SOURCE,\n type: 'section.select',\n shopId,\n sectionId,\n ...(section !== undefined ? { section } : {}),\n sections: snapshot.sections,\n ...(schema !== undefined ? { schema } : {}),\n ...(schemas !== undefined ? { schemas } : {}),\n }\n target.postMessage(message, adminOrigin)\n },\n dispose: () => {\n transport.removeEventListener('message', onMessage)\n },\n }\n}\n\nexport function createStorefrontEditorHostBridge({\n onReady,\n onSelectSection,\n previewOrigin,\n shopId,\n target,\n transport,\n}: CreateStorefrontEditorHostBridgeArgs): StorefrontEditorHostBridge {\n const onMessage = (event: StorefrontEditorMessageEvent): void => {\n if (event.origin !== previewOrigin) return\n if (event.source !== undefined && event.source !== null && event.source !== target) return\n const ready = parsePreviewReady(event.data, shopId)\n if (ready !== null) {\n onReady?.({\n sections: ready.sections,\n ...(ready.schemas !== undefined ? { schemas: ready.schemas } : {}),\n ...(ready.globalInputs !== undefined ? { globalInputs: ready.globalInputs } : {}),\n ...(ready.templates !== undefined ? { templates: ready.templates } : {}),\n ...(ready.sectionGroups !== undefined ? { sectionGroups: ready.sectionGroups } : {}),\n })\n return\n }\n const message = parsePreviewSelection(event.data, shopId)\n if (message === null || isReservedSectionId(message.sectionId)) return\n onSelectSection({\n sectionId: message.sectionId,\n ...(message.section !== undefined ? { section: message.section } : {}),\n ...(message.sections !== undefined ? { sections: message.sections } : {}),\n ...(message.schema !== undefined ? { schema: message.schema } : {}),\n ...(message.schemas !== undefined ? { schemas: message.schemas } : {}),\n })\n }\n\n transport.addEventListener('message', onMessage)\n\n return {\n patchSection: (sectionId, settings) => {\n if (isReservedSectionId(sectionId)) return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'settings.patchSection',\n shopId,\n sectionId,\n settings,\n })\n },\n patchGlobal: (settings) => {\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'settings.patchGlobal',\n shopId,\n settings,\n })\n },\n insertSection: (section, index) => {\n if (isReservedSectionId(section.id)) return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'sections.insert',\n shopId,\n section,\n ...(index !== undefined ? { index } : {}),\n })\n },\n removeSection: (sectionId) => {\n if (isReservedSectionId(sectionId)) return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'sections.remove',\n shopId,\n sectionId,\n })\n },\n reorderSection: (sectionId, index) => {\n if (isReservedSectionId(sectionId)) return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'sections.reorder',\n shopId,\n sectionId,\n index,\n })\n },\n patchBlock: (sectionId, blockId, settings) => {\n if (isReservedSectionId(sectionId)) return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'settings.patchBlock',\n shopId,\n sectionId,\n blockId,\n settings,\n })\n },\n insertBlock: (sectionId, block, index) => {\n if (isReservedSectionId(sectionId)) return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'blocks.insert',\n shopId,\n sectionId,\n block,\n ...(index !== undefined ? { index } : {}),\n })\n },\n removeBlock: (sectionId, blockId) => {\n if (isReservedSectionId(sectionId)) return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'blocks.remove',\n shopId,\n sectionId,\n blockId,\n })\n },\n reorderBlock: (sectionId, blockId, index) => {\n if (isReservedSectionId(sectionId)) return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'blocks.reorder',\n shopId,\n sectionId,\n blockId,\n index,\n })\n },\n replaceTemplate: (handle, document) => {\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'template.replace',\n shopId,\n handle,\n document,\n })\n },\n replaceSectionGroup: (handle, document) => {\n if (handle.trim() === '') return\n postHostMessage(target, previewOrigin, {\n source: HOST_SOURCE,\n type: 'sectionGroup.replace',\n shopId,\n handle,\n document,\n })\n },\n dispose: () => {\n transport.removeEventListener('message', onMessage)\n },\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cart/CartForm.ts","../src/react/nonce.ts","../src/analytics/emitter.ts","../src/analytics/analytics-bus.ts","../src/analytics/pixel-transport.ts"],"names":["CartForm"],"mappings":";;;;;AAaA,SAAS,eAAe,KAAA,EAAyB;AAC/C,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,MAAM,OAAA,GAAU,MAAM,IAAA,EAAK;AAC3B,EAAA,IAAI,QAAQ,UAAA,CAAW,GAAG,KAAK,OAAA,CAAQ,UAAA,CAAW,GAAG,CAAA,EAAG;AACtD,IAAA,IAAI;AACF,MAAA,OAAO,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA,IAC3B,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,iBAAiB,QAAA,EAAyC;AACxE,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,GAAA,CAAI,YAAY,CAAA;AACxC,EAAA,MAAM,SAA8B,EAAC;AACrC,EAAA,KAAA,MAAW,OAAO,IAAI,GAAA,CAAI,QAAA,CAAS,IAAA,EAAM,CAAA,EAAG;AAC1C,IAAA,IAAI,QAAQ,YAAA,EAAc;AAC1B,IAAA,MAAM,SAAS,QAAA,CAAS,MAAA,CAAO,GAAG,CAAA,CAAE,IAAI,cAAc,CAAA;AACtD,IAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA,CAAO,WAAW,CAAA,GAAI,MAAA,CAAO,CAAC,CAAA,GAAI,MAAA;AAAA,EAClD;AACA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,OAAO,MAAA,KAAW,Q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AAAA,MACH;AAAA,IACF,CAAA;AAAA,IACA,KAAA,GAAQ;AACN,MAAA,OAAA,CAAQ,UAAU,KAAA,EAAM;AAAA,IAC1B;AAAA,GACF;AACF;;;ACjCA,IAAM,gBAAA,GAAmB,uBAAA;AACzB,IAAM,kBAAA,GAAqB,EAAA;AAOpB,SAAS,qBAAqB,OAAA,EAAgD;AACnF,EAAA,MAAM,QAAA,GAAW,QAAQ,QAAA,IAAY,gBAAA;AAGrC,EAAA,IAAI,CAAC,WAAA,CAAY,IAAA,CAAK,QAAQ,CAAA,EAAG;AAC/B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kEAAA,EAAqE,QAAQ,CAAA,CAAE,CAAA;AAAA,EACjG;AACA,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,kBAAA;AACvC,EAAA,MAAM,OAAO,OAAA,CAAQ,IAAA;AACrB,EAAA,IAAI,QAAsB,EAAC;AAE3B,EAAA,MAAM,QAAQ,MAAY;AACxB,IAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACxB,IAAA,MAAM,KAAA,GAAQ,KAAA;AACd,IAAA,KAAA,GAAQ,EAAC;AACT,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,SAAA,CAAU,EAAE,MAAA,EAAQ,KAAA,EAAO,CAAC,CAAA;AAAA,EAClD,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,OAAO,KAAA,EAAO;AACZ,MAAA,KAAA,CAAM,KAAK,KAAK,CAAA;AAChB,MAAA,IAAI,KAAA,CAAM,MAAA,IAAU,SAAA,EAAW,KAAA,EAAM;AAAA,IACvC,CAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-XMTWFJCZ.js","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { CART_FORM_ACTIONS, type CartFormAction } from './actions'\n\nexport interface CartFormProps {\n readonly action: CartFormAction\n}\n\nexport interface CartFormInputResult {\n readonly action: CartFormAction | null\n readonly inputs: Record<string, any>\n}\n\nfunction parseFormValue(value: unknown): unknown {\n if (typeof value !== 'string') return value\n const trimmed = value.trim()\n if (trimmed.startsWith('{') || trimmed.startsWith('[')) {\n try {\n return JSON.parse(trimmed) as unknown\n } catch {\n return value\n }\n }\n return value\n}\n\nexport function getCartFormInput(formData: FormData): CartFormInputResult {\n const action = formData.get('cartAction')\n const inputs: Record<string, any> = {}\n for (const key of new Set(formData.keys())) {\n if (key === 'cartAction') continue\n const values = formData.getAll(key).map(parseFormValue)\n inputs[key] = values.length === 1 ? values[0] : values\n }\n return {\n action: typeof action === 'string' ? (action as CartFormAction) : null,\n inputs,\n }\n}\n\n/**\n * Lightweight CartForm surface marker for Hydrogen-style imports. React render integration can wrap\n * this constant surface; the load-bearing API today is the stable ACTIONS contract used by handlers.\n */\nexport const CartForm = Object.assign(\n function CartForm(_props: CartFormProps): null {\n return null\n },\n { ACTIONS: CART_FORM_ACTIONS, getFormInput: getCartFormInput },\n)\n","import * as ReactRuntime from 'react'\nimport { createContext, createElement, useContext, type ReactNode } from 'react'\n\nconst NonceContext = createContext<string | undefined>(undefined)\n\nexport interface NonceProviderProps {\n readonly children?: ReactNode\n readonly nonce?: string\n}\n\nexport type BoundNonceProvider = (props: { readonly children?: ReactNode }) => ReactNode\n\nexport function NonceProvider(props: NonceProviderProps): ReactNode {\n return createElement(NonceContext.Provider, { value: props.nonce }, props.children)\n}\n\nexport function createNonceProvider(nonce: string): BoundNonceProvider {\n return function BoundNonceProvider(props: { readonly children?: ReactNode }): ReactNode {\n return createElement(NonceContext.Provider, { value: nonce }, props.children)\n }\n}\n\n/** Hydrogen-compatible nonce hook. */\nexport function useNonce(): string | undefined {\n if (!hasReactDispatcher()) return undefined\n return useContext(NonceContext)\n}\n\nfunction hasReactDispatcher(): boolean {\n const runtime = ReactRuntime as unknown as {\n __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE?: { H?: unknown }\n __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?: {\n ReactCurrentDispatcher?: { current?: unknown }\n }\n }\n return Boolean(\n runtime.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE?.H ??\n runtime.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentDispatcher?.current,\n )\n}\n","import type { AnalyticsEventMap, AnalyticsEventName } from './events'\n\nexport type EventHandler<E extends AnalyticsEventName> = (payload: AnalyticsEventMap[E]) => void\n\n/** A framework-agnostic typed pub/sub bus (Hydrogen `useAnalytics` shape, minus React). */\nexport interface AnalyticsEmitter {\n subscribe<E extends AnalyticsEventName>(event: E, handler: EventHandler<E>): () => void\n publish<E extends AnalyticsEventName>(event: E, payload: AnalyticsEventMap[E]): void\n}\n\nexport function createAnalyticsEmitter(): AnalyticsEmitter {\n const handlers = new Map<AnalyticsEventName, Set<(payload: unknown) => void>>()\n return {\n subscribe(event, handler) {\n const set = handlers.get(event) ?? new Set<(payload: unknown) => void>()\n const erased = handler as (payload: unknown) => void\n set.add(erased)\n handlers.set(event, set)\n return () => {\n set.delete(erased)\n }\n },\n publish(event, payload) {\n const set = handlers.get(event)\n if (set === undefined) return\n // Snapshot so a handler unsubscribing mid-dispatch doesn't skip a sibling.\n for (const handler of [...set]) {\n try {\n handler(payload)\n } catch {\n // Isolate: a throwing subscriber must not break sibling handlers or the downstream pixel send.\n }\n }\n },\n }\n}\n","import { isGranted, type ConsentState } from './consent'\nimport { createAnalyticsEmitter, type AnalyticsEmitter } from './emitter'\nimport type { AnalyticsContext, AnalyticsEventMap, AnalyticsEventName } from './events'\nimport type { PixelTransport } from './pixel-transport'\n\nexport interface AnalyticsBusOptions {\n readonly transport: PixelTransport\n /** Legacy consent seam retained for API compatibility while Storefront consent UI is disabled. */\n readonly getConsent: () => ConsentState\n /** Ambient context (shopId, geo, url) attached to each pixel event. */\n readonly getContext?: () => AnalyticsContext\n /** Clock seam for deterministic timestamps in tests. */\n readonly now?: () => string\n}\n\nexport interface AnalyticsBus {\n readonly emitter: AnalyticsEmitter\n publish<E extends AnalyticsEventName>(event: E, payload: AnalyticsEventMap[E]): void\n flush(): void\n}\n\n/**\n * Wire the emitter to the pixel. Every published event reaches theme subscribers (via the emitter) and\n * is also recorded to the pixel. Consent gating is temporarily disabled with the UI; the consent seam\n * remains so a proper replacement can reinstate the policy without changing theme APIs.\n */\nexport function createAnalyticsBus(options: AnalyticsBusOptions): AnalyticsBus {\n const emitter = createAnalyticsEmitter()\n const now = options.now ?? ((): string => new Date().toISOString())\n return {\n emitter,\n publish(event, payload) {\n emitter.publish(event, payload)\n const consented = isGranted(options.getConsent(), 'analytics')\n const context = options.getContext?.() ?? {}\n if (consented) {\n options.transport.record({ event, payload, context, timestamp: now(), consent: true })\n return\n }\n // Kept for the future consent replacement. Today isGranted() is fail-open, so this branch is not\n // reached in production.\n if (event === 'page_viewed') {\n options.transport.record({\n event,\n payload: {} as AnalyticsEventMap[typeof event],\n context,\n timestamp: now(),\n consent: false,\n })\n }\n },\n flush() {\n options.transport.flush()\n },\n }\n}\n","import type { PixelEvent } from './events'\n\n/** The actual network send. Injectable so tests don't touch the network. */\nexport type PixelSend = (endpoint: string, body: string) => void\n\nexport interface PixelTransportOptions {\n /** Same-origin carve-out endpoint (default '/api/storefront/pixel') — never cross-origin. */\n readonly endpoint?: string\n readonly batchSize?: number\n /**\n * The actual network send. Required + injected: the browser sender (`sendBeacon`/keepalive `fetch`)\n * is DOM-specific and lives in the React layer, keeping this batching core framework-agnostic and\n * unit-testable with a spy. The provider wires the real sender.\n */\n readonly send: PixelSend\n}\n\nexport interface PixelTransport {\n record(event: PixelEvent): void\n flush(): void\n}\n\nconst DEFAULT_ENDPOINT = '/api/storefront/pixel'\nconst DEFAULT_BATCH_SIZE = 10\n\n/**\n * Batches pixel events and POSTs them to the same-origin carve-out. Flushes on `batchSize` or an\n * explicit `flush()` (the provider flushes on page-hide). The endpoint is same-origin so themes need\n * no CORS and no token is exposed in the browser.\n */\nexport function createPixelTransport(options: PixelTransportOptions): PixelTransport {\n const endpoint = options.endpoint ?? DEFAULT_ENDPOINT\n // SECURITY: the pixel must stay same-origin (no CORS, no token leak). Reject a non-relative or\n // protocol-relative endpoint so a misconfigured theme can't exfiltrate visitor data (e.g. clientIp).\n if (!/^\\/(?!\\/)/.test(endpoint)) {\n throw new Error(`pixel endpoint must be a same-origin path starting with '/'; got: ${endpoint}`)\n }\n const batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE\n const send = options.send\n let queue: PixelEvent[] = []\n\n const flush = (): void => {\n if (queue.length === 0) return\n const batch = queue\n queue = []\n send(endpoint, JSON.stringify({ events: batch }))\n }\n\n return {\n record(event) {\n queue.push(event)\n if (queue.length >= batchSize) flush()\n },\n flush,\n }\n}\n"]}
|