@kotao/storefront 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/{bridge-ZKbKqgFd.d.ts → bridge-CfNBWu0H.d.ts} +24 -3
- package/dist/{chunk-EG34HLSX.js → chunk-DTKLAOKR.js} +26 -7
- package/dist/chunk-DTKLAOKR.js.map +1 -0
- package/dist/{chunk-O6YZEY7X.js → chunk-RFKLO6TD.js} +220 -8
- package/dist/chunk-RFKLO6TD.js.map +1 -0
- package/dist/editor.d.ts +4 -4
- package/dist/editor.js +1 -1
- package/dist/events-react.d.ts +3 -1
- package/dist/events-react.js +5 -3
- package/dist/events-react.js.map +1 -1
- package/dist/{hydrogen-Bu7k0kE4.d.ts → hydrogen-CqDMW3YC.d.ts} +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -3
- package/dist/react-router.d.ts +11 -1
- package/dist/react-router.js +2 -2
- package/dist/react-router.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/settings.d.ts +2 -2
- package/dist/{store-DO08fzJi.d.ts → store-ZzoBbWir.d.ts} +1 -1
- package/package.json +2 -2
- package/dist/chunk-EG34HLSX.js.map +0 -1
- package/dist/chunk-O6YZEY7X.js.map +0 -1
package/README.md
CHANGED
|
@@ -27,6 +27,13 @@ The one real migration diff is `request.cf` → `context.geo`.
|
|
|
27
27
|
boundaries/registry helpers.
|
|
28
28
|
- `@kotao/storefront/react-router` — the React Router 8 binding (`getKotaoLoadContext`).
|
|
29
29
|
|
|
30
|
+
## Event approval offers
|
|
31
|
+
|
|
32
|
+
`EventApprovalOffer` from `@kotao/storefront/events/react` accepts an optional `formatDateTime`
|
|
33
|
+
callback for the visible event start and offer expiry. Format these in the event's locale and a
|
|
34
|
+
fixed time zone so server and browser output agree. The original timestamps remain unchanged in
|
|
35
|
+
the `time` elements and the offer lifecycle.
|
|
36
|
+
|
|
30
37
|
## Hydrogen editor preview
|
|
31
38
|
|
|
32
39
|
`createHydrogenEditorPreviewRuntime` projects manifest-authorized operations into an in-memory
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as ThemeSettingsStore, R as ResolvedSettings, a as ResolvedSection, b as ResolvedBlock } from './store-
|
|
1
|
+
import { T as ThemeSettingsStore, R as ResolvedSettings, a as ResolvedSection, b as ResolvedBlock } from './store-ZzoBbWir.js';
|
|
2
2
|
|
|
3
3
|
interface StorefrontEditorMessageTarget {
|
|
4
4
|
postMessage(message: unknown, targetOrigin: string): void;
|
|
@@ -15,6 +15,12 @@ interface StorefrontEditorMessageSource {
|
|
|
15
15
|
interface StorefrontEditorPointerEvent {
|
|
16
16
|
readonly target?: unknown;
|
|
17
17
|
readonly relatedTarget?: unknown;
|
|
18
|
+
readonly button?: number;
|
|
19
|
+
readonly defaultPrevented?: boolean;
|
|
20
|
+
readonly metaKey?: boolean;
|
|
21
|
+
readonly ctrlKey?: boolean;
|
|
22
|
+
readonly shiftKey?: boolean;
|
|
23
|
+
readonly altKey?: boolean;
|
|
18
24
|
preventDefault?(): void;
|
|
19
25
|
stopPropagation?(): void;
|
|
20
26
|
}
|
|
@@ -56,6 +62,13 @@ interface StorefrontEditorDocument {
|
|
|
56
62
|
readonly defaultView?: {
|
|
57
63
|
readonly innerWidth: number;
|
|
58
64
|
readonly innerHeight: number;
|
|
65
|
+
readonly location?: {
|
|
66
|
+
readonly href: string;
|
|
67
|
+
readonly origin: string;
|
|
68
|
+
};
|
|
69
|
+
requestAnimationFrame?(callback: (now: number) => void): number;
|
|
70
|
+
cancelAnimationFrame?(requestId: number): void;
|
|
71
|
+
open?(url: string, target: '_blank', features: 'noopener,noreferrer'): void;
|
|
59
72
|
addEventListener?(type: 'scroll' | 'resize', listener: () => void, capture?: boolean): void;
|
|
60
73
|
removeEventListener?(type: 'scroll' | 'resize', listener: () => void, capture?: boolean): void;
|
|
61
74
|
};
|
|
@@ -153,6 +166,7 @@ interface StorefrontEditorValuesDocument {
|
|
|
153
166
|
}
|
|
154
167
|
interface StorefrontEditorReady {
|
|
155
168
|
readonly sections: readonly ResolvedSection[];
|
|
169
|
+
readonly visualReadyProtocol?: 1;
|
|
156
170
|
readonly global?: ResolvedSettings;
|
|
157
171
|
readonly schemas?: Readonly<Record<string, StorefrontEditorSectionSchema>>;
|
|
158
172
|
readonly globalInputs?: readonly StorefrontEditorSettingInput[];
|
|
@@ -162,6 +176,7 @@ interface StorefrontEditorReady {
|
|
|
162
176
|
}
|
|
163
177
|
interface StorefrontEditorHostBridge {
|
|
164
178
|
requestReady(): void;
|
|
179
|
+
requestVisualReady(requestId: string): void;
|
|
165
180
|
hoverSection(sectionId: string | null): void;
|
|
166
181
|
activateSection(sectionId: string | null, blockId?: string): void;
|
|
167
182
|
patchSection(sectionId: string, settings: ResolvedSettings): void;
|
|
@@ -176,8 +191,12 @@ interface StorefrontEditorHostBridge {
|
|
|
176
191
|
replaceTemplate(handle: string, document: StorefrontEditorValuesDocument): void;
|
|
177
192
|
replaceSectionGroup(handle: string, document: StorefrontEditorValuesDocument): void;
|
|
178
193
|
replaceAppExtensions(extensions: readonly StorefrontEditorAppExtensionPreview[]): void;
|
|
194
|
+
setInspectorEnabled(enabled: boolean): void;
|
|
179
195
|
dispose(): void;
|
|
180
196
|
}
|
|
197
|
+
interface StorefrontEditorNavigationRequest {
|
|
198
|
+
readonly href: string;
|
|
199
|
+
}
|
|
181
200
|
interface StorefrontEditorAppExtensionPreview {
|
|
182
201
|
readonly instanceId: string;
|
|
183
202
|
readonly kind: 'app_embed' | 'app_section' | 'app_block';
|
|
@@ -217,7 +236,9 @@ interface CreateStorefrontEditorHostBridgeArgs {
|
|
|
217
236
|
readonly onSelectSection: (selection: StorefrontEditorSelection) => void;
|
|
218
237
|
readonly onCanvasAction?: (action: StorefrontEditorCanvasAction) => void;
|
|
219
238
|
readonly onHoverSection?: (sectionId: string | null) => void;
|
|
239
|
+
readonly onNavigate?: (request: StorefrontEditorNavigationRequest) => void;
|
|
220
240
|
readonly onReady?: (ready: StorefrontEditorReady) => void;
|
|
241
|
+
readonly onVisualReady?: (requestId: string) => void;
|
|
221
242
|
readonly previewOrigin: string;
|
|
222
243
|
readonly resolveTarget?: () => StorefrontEditorMessageTarget | null;
|
|
223
244
|
readonly shopId: string;
|
|
@@ -234,6 +255,6 @@ declare function positionStorefrontEditorCanvasToolbar(anchor: StorefrontEditorR
|
|
|
234
255
|
readonly height: number;
|
|
235
256
|
}): StorefrontEditorCanvasPosition;
|
|
236
257
|
declare function createStorefrontEditorBridge({ adminOrigin, document: editorDocument, globalInputs, themeStyles, schemas, sectionGroups, shopId, store, target, templates, transport, }: CreateStorefrontEditorBridgeArgs): StorefrontEditorBridge;
|
|
237
|
-
declare function createStorefrontEditorHostBridge({ onCanvasAction, onHoverSection, onReady, onSelectSection, previewOrigin, resolveTarget, shopId, target, transport, }: CreateStorefrontEditorHostBridgeArgs): StorefrontEditorHostBridge;
|
|
258
|
+
declare function createStorefrontEditorHostBridge({ onCanvasAction, onHoverSection, onNavigate, onReady, onSelectSection, onVisualReady, previewOrigin, resolveTarget, shopId, target, transport, }: CreateStorefrontEditorHostBridgeArgs): StorefrontEditorHostBridge;
|
|
238
259
|
|
|
239
|
-
export { type CreateStorefrontEditorBridgeArgs as C, type StorefrontEditorMessageSource as S, type StorefrontEditorMessageTarget as a, type CreateStorefrontEditorHostBridgeArgs as b, type StorefrontEditorAppExtensionPreview as c, type StorefrontEditorBlockSchema as d, type StorefrontEditorBridge as e, type StorefrontEditorCanvasAction as f, type StorefrontEditorCanvasBlockAction as g, type StorefrontEditorCanvasPosition as h, type StorefrontEditorCanvasSectionAction as i, type StorefrontEditorDocument as j, type StorefrontEditorHostBridge as k, type StorefrontEditorMessageEvent as l, type
|
|
260
|
+
export { positionStorefrontEditorCanvasToolbar as A, type CreateStorefrontEditorBridgeArgs as C, type StorefrontEditorMessageSource as S, type StorefrontEditorMessageTarget as a, type CreateStorefrontEditorHostBridgeArgs as b, type StorefrontEditorAppExtensionPreview as c, type StorefrontEditorBlockSchema as d, type StorefrontEditorBridge as e, type StorefrontEditorCanvasAction as f, type StorefrontEditorCanvasBlockAction as g, type StorefrontEditorCanvasPosition as h, type StorefrontEditorCanvasSectionAction as i, type StorefrontEditorDocument as j, type StorefrontEditorHostBridge as k, type StorefrontEditorMessageEvent as l, type StorefrontEditorNavigationRequest as m, type StorefrontEditorReady as n, type StorefrontEditorRect as o, type StorefrontEditorSectionPreset as p, type StorefrontEditorSectionPresetBlock as q, type StorefrontEditorSectionSchema as r, type StorefrontEditorSelection as s, type StorefrontEditorSelectionScope as t, type StorefrontEditorSettingInput as u, type StorefrontEditorSettingOption as v, type StorefrontEditorThemeStyle as w, type StorefrontEditorValuesDocument as x, createStorefrontEditorBridge as y, createStorefrontEditorHostBridge as z };
|
|
@@ -2,7 +2,7 @@ import { CONSENT_BUCKETS, readConsentCookie, CART_FORM_ACTIONS } from './chunk-O
|
|
|
2
2
|
import { fetchThemeSettings } from './chunk-2MRB6SMP.js';
|
|
3
3
|
import { encodeUtf8Base64Url, toBase64Url, fromBase64Url, decodeBase64UrlUtf8 } from './chunk-CKGI3Y7L.js';
|
|
4
4
|
import { createEventsClient, normalizeStorefrontHeaders } from './chunk-R4N565GX.js';
|
|
5
|
-
import { HOSTED_SURFACE_DESIGN_INPUTS, MARKET_ID_HEADER, MARKET_DEFAULT_LOCALE_HEADER, MARKET_CANONICAL_URL_HEADER, MARKET_ROOT_URLS_HEADER, MARKET_PATH_PREFIX_HEADER, MARKET_THEME_ID_HEADER, MARKET_SETTINGS_ENVIRONMENT_HEADER, MARKET_ALTERNATE_LOCALES_HEADER, SHOP_HEADER, SHOP_SIGNATURE_HEADER, SHOP_ORIGIN_HEADER, autoRedirectEnabled, AUTO_REDIRECT_COUNTRY_HEADER, signShopContext } from '@kotao/storefront-contracts';
|
|
5
|
+
import { HOSTED_SURFACE_DESIGN_INPUTS, MARKET_ID_HEADER, MARKET_DEFAULT_LOCALE_HEADER, MARKET_CANONICAL_URL_HEADER, MARKET_ROOT_URLS_HEADER, MARKET_PATH_PREFIX_HEADER, MARKET_THEME_ID_HEADER, MARKET_SETTINGS_ENVIRONMENT_HEADER, MARKET_ALTERNATE_LOCALES_HEADER, SHOP_HEADER, SHOP_SIGNATURE_HEADER, SHOP_ORIGIN_HEADER, autoRedirectEnabled, AUTO_REDIRECT_COUNTRY_HEADER, rolloutVisitorCookieHeader, signShopContext } from '@kotao/storefront-contracts';
|
|
6
6
|
export { MARKET_ALTERNATE_LOCALES_HEADER, MARKET_CANONICAL_URL_HEADER, MARKET_DEFAULT_LOCALE_HEADER, MARKET_ID_HEADER, MARKET_PATH_PREFIX_HEADER, MARKET_ROOT_URLS_HEADER, MARKET_SETTINGS_ENVIRONMENT_HEADER, MARKET_THEME_ID_HEADER } from '@kotao/storefront-contracts';
|
|
7
7
|
|
|
8
8
|
// src/cache/cache.ts
|
|
@@ -110,12 +110,19 @@ function readCartIdCookie(cookieHeader) {
|
|
|
110
110
|
if (cookieHeader == null || cookieHeader === "") return null;
|
|
111
111
|
const match = cookieHeader.split(";").map((part) => part.trim()).find((part) => part.startsWith(`${CART_ID_COOKIE}=`));
|
|
112
112
|
if (match === void 0) return null;
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
try {
|
|
114
|
+
const value = decodeURIComponent(match.slice(CART_ID_COOKIE.length + 1));
|
|
115
|
+
return value === "" ? null : value;
|
|
116
|
+
} catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
115
119
|
}
|
|
116
120
|
function buildCartIdCookie(cartId) {
|
|
117
121
|
return `${CART_ID_COOKIE}=${encodeURIComponent(cartId)}; Path=/; Max-Age=${CART_MAX_AGE}; SameSite=Lax; Secure; HttpOnly`;
|
|
118
122
|
}
|
|
123
|
+
function clearCartIdCookie() {
|
|
124
|
+
return `${CART_ID_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax; Secure; HttpOnly`;
|
|
125
|
+
}
|
|
119
126
|
|
|
120
127
|
// src/customer-account/session.ts
|
|
121
128
|
var CUSTOMER_SESSION_COOKIE = "kotao_customer_session";
|
|
@@ -1195,6 +1202,9 @@ function createCustomerAccountClient(opts) {
|
|
|
1195
1202
|
}
|
|
1196
1203
|
},
|
|
1197
1204
|
async account() {
|
|
1205
|
+
if (token === null) {
|
|
1206
|
+
throw new CustomerAccountError("unauthenticated", "account read: not logged in");
|
|
1207
|
+
}
|
|
1198
1208
|
return readJson(await proxyGet("/account"), "account read");
|
|
1199
1209
|
},
|
|
1200
1210
|
async orders(options) {
|
|
@@ -1920,6 +1930,8 @@ async function createKotaoContext(request, env, executionCtx, deps) {
|
|
|
1920
1930
|
const geoCountry = autoCountry ? geo?.country?.trim().toUpperCase() ?? null : null;
|
|
1921
1931
|
const apiCountry = editorCountry ?? cookieCountry ?? (geoCountry !== null && API_COUNTRY_RE.test(geoCountry) ? geoCountry : null);
|
|
1922
1932
|
const extraHeaders = {};
|
|
1933
|
+
const rolloutVisitorCookie = rolloutVisitorCookieHeader(request.headers.get("cookie"));
|
|
1934
|
+
if (rolloutVisitorCookie !== null) extraHeaders["cookie"] = rolloutVisitorCookie;
|
|
1923
1935
|
const requestId = request.headers.get(REQUEST_ID_HEADER)?.trim();
|
|
1924
1936
|
if (requestId !== void 0 && requestId.length > 0) extraHeaders[REQUEST_ID_HEADER] = requestId;
|
|
1925
1937
|
const deploymentId = request.headers.get(DEPLOYMENT_ID_HEADER)?.trim();
|
|
@@ -1938,6 +1950,7 @@ async function createKotaoContext(request, env, executionCtx, deps) {
|
|
|
1938
1950
|
cache
|
|
1939
1951
|
});
|
|
1940
1952
|
const eventHeaders = new Headers(signedShopContextHeaders);
|
|
1953
|
+
if (rolloutVisitorCookie !== null) eventHeaders.set("cookie", rolloutVisitorCookie);
|
|
1941
1954
|
if (apiLocale !== void 0) eventHeaders.set("x-kotao-locale", apiLocale);
|
|
1942
1955
|
if (apiCountry !== null) eventHeaders.set("x-kotao-country", apiCountry);
|
|
1943
1956
|
for (const [name, value] of Object.entries(extraHeaders)) eventHeaders.set(name, value);
|
|
@@ -1980,7 +1993,13 @@ async function createKotaoContext(request, env, executionCtx, deps) {
|
|
|
1980
1993
|
loadThemeSettings: (opts) => fetchThemeSettings({
|
|
1981
1994
|
endpoint: settingsEndpoint,
|
|
1982
1995
|
allowCrossOrigin: true,
|
|
1983
|
-
...signedShopContextHeaders
|
|
1996
|
+
...signedShopContextHeaders || rolloutVisitorCookie !== null || apiCountry !== null ? {
|
|
1997
|
+
shopContextHeaders: {
|
|
1998
|
+
...signedShopContextHeaders ?? {},
|
|
1999
|
+
...rolloutVisitorCookie === null ? {} : { cookie: rolloutVisitorCookie },
|
|
2000
|
+
...apiCountry === null ? {} : { "x-kotao-country": apiCountry }
|
|
2001
|
+
}
|
|
2002
|
+
} : {},
|
|
1984
2003
|
...opts?.fetch ? { fetch: opts.fetch } : {},
|
|
1985
2004
|
...opts?.templateHandle ? { templateHandle: opts.templateHandle } : {}
|
|
1986
2005
|
})
|
|
@@ -2035,6 +2054,6 @@ function createEphemeralSession(isLoggedIn) {
|
|
|
2035
2054
|
};
|
|
2036
2055
|
}
|
|
2037
2056
|
|
|
2038
|
-
export { CART_ID_COOKIE, CHECKOUT_CONSENT_CATEGORIES, CHECKOUT_CONSENT_PARAM_PREFIX, CHECKOUT_DESIGN_TOKEN_INPUTS, CUSTOMER_SESSION_COOKIE, CacheCustom, CacheLong, CacheNone, CacheShort, CustomerAccountError, DEFAULT_HOSTED_SESSION_MAX_AGE, DEFAULT_SESSION_MAX_AGE, GEO_HEADER, GEO_SIGNATURE_HEADER, HOSTED_CUSTOMER_CSRF_COOKIE, HOSTED_CUSTOMER_CSRF_HEADER, HOSTED_CUSTOMER_SESSION_COOKIE, LOCALIZATION_COOKIE, MAX_HOSTED_SESSION_MAX_AGE, MAX_LEGACY_CUSTOMER_SESSION_TOKEN_LENGTH, ROUTING_LOCALE_HEADER, ROUTING_ORIGINAL_PATHNAME_HEADER, StorefrontDefaultCache, StorefrontQueryTimeoutError, StorefrontUpstreamError, buildCartIdCookie, buildCustomerSessionCookie, buildHostedCustomerSessionCookie, buildLocalizationCookie, cartGetIdDefault, cartSetIdDefault, clearCustomerSessionCookie, clearHostedCustomerSessionCookie, clearLegacyCustomerSessionCookie, createCache, createCartHandler, createCustomerAccountClient, createKotaoContext, createStorefrontClient, createWithCache, decodeCheckoutConsent, encodeCheckoutConsent, extractCheckoutDesignTokens, generateCacheControlHeader, isLocalePathSegment, localeFromAcceptLanguage, localeFromPathname, localeFromRequest, localizePath, marketContextFromHeaders, originalPathnameFromRequest, readCartIdCookie, readCustomerSessionToken, readHostedCustomerCsrfToken, readHostedCustomerSessionToken, readLegacyCustomerSessionToken, readLocalizationCookie, resolveCheckoutUrl, shopHostname, signGeo, stripLocalePrefixFromPathname, stripLocalePrefixFromRequest, trustedShopOriginFromHeaders, verifyGeo };
|
|
2039
|
-
//# sourceMappingURL=chunk-
|
|
2040
|
-
//# sourceMappingURL=chunk-
|
|
2057
|
+
export { CART_ID_COOKIE, CHECKOUT_CONSENT_CATEGORIES, CHECKOUT_CONSENT_PARAM_PREFIX, CHECKOUT_DESIGN_TOKEN_INPUTS, CUSTOMER_SESSION_COOKIE, CacheCustom, CacheLong, CacheNone, CacheShort, CustomerAccountError, DEFAULT_HOSTED_SESSION_MAX_AGE, DEFAULT_SESSION_MAX_AGE, GEO_HEADER, GEO_SIGNATURE_HEADER, HOSTED_CUSTOMER_CSRF_COOKIE, HOSTED_CUSTOMER_CSRF_HEADER, HOSTED_CUSTOMER_SESSION_COOKIE, LOCALIZATION_COOKIE, MAX_HOSTED_SESSION_MAX_AGE, MAX_LEGACY_CUSTOMER_SESSION_TOKEN_LENGTH, ROUTING_LOCALE_HEADER, ROUTING_ORIGINAL_PATHNAME_HEADER, StorefrontDefaultCache, StorefrontQueryTimeoutError, StorefrontUpstreamError, buildCartIdCookie, buildCustomerSessionCookie, buildHostedCustomerSessionCookie, buildLocalizationCookie, cartGetIdDefault, cartSetIdDefault, clearCartIdCookie, clearCustomerSessionCookie, clearHostedCustomerSessionCookie, clearLegacyCustomerSessionCookie, createCache, createCartHandler, createCustomerAccountClient, createKotaoContext, createStorefrontClient, createWithCache, decodeCheckoutConsent, encodeCheckoutConsent, extractCheckoutDesignTokens, generateCacheControlHeader, isLocalePathSegment, localeFromAcceptLanguage, localeFromPathname, localeFromRequest, localizePath, marketContextFromHeaders, originalPathnameFromRequest, readCartIdCookie, readCustomerSessionToken, readHostedCustomerCsrfToken, readHostedCustomerSessionToken, readLegacyCustomerSessionToken, readLocalizationCookie, resolveCheckoutUrl, shopHostname, signGeo, stripLocalePrefixFromPathname, stripLocalePrefixFromRequest, trustedShopOriginFromHeaders, verifyGeo };
|
|
2058
|
+
//# sourceMappingURL=chunk-DTKLAOKR.js.map
|
|
2059
|
+
//# sourceMappingURL=chunk-DTKLAOKR.js.map
|